parent
b0a7de6b69
commit
5402fe2190
|
@ -59,7 +59,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serde_json::to_string(&graphic).unwrap(),
|
serde_json::to_string(&graphic).unwrap(),
|
||||||
r#"{"children":[{"dataType":"wpShape","children":[{"type":"shape","data":{"children":[{"type":"textbox","data":{"children":[{"children":[{"type":"paragraph","data":{"id":"12345678","children":[{"type":"run","data":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"children":[{"type":"text","data":{"preserveSpace":true,"text":"pattern1"}}]}}],"property":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"divId":null},"hasNumbering":false}}],"has_numbering":false}],"hasNumbering":false}}]}}]}]}"#
|
r#"{"children":[{"dataType":"wpShape","children":[{"type":"shape","data":{"children":[{"type":"textbox","data":{"children":[{"children":[{"type":"paragraph","data":{"id":"12345678","children":[{"type":"run","data":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"children":[{"type":"text","data":{"preserveSpace":true,"text":"pattern1"}}]}}],"property":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"keepNext":false,"keepLines":false,"pageBreakBefore":false,"windowControl":false,"divId":null},"hasNumbering":false}}],"has_numbering":false}],"hasNumbering":false}}]}}]}]}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ mod tests {
|
||||||
.num_style_link("style1");
|
.num_style_link("style1");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serde_json::to_string(&c).unwrap(),
|
serde_json::to_string(&c).unwrap(),
|
||||||
r#"{"id":0,"styleLink":null,"numStyleLink":"style1","levels":[{"level":1,"start":1,"format":"decimal","text":"%4.","jc":"left","pstyle":null,"paragraphProperty":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"divId":null},"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"suffix":"tab"}]}"#
|
r#"{"id":0,"styleLink":null,"numStyleLink":"style1","levels":[{"level":1,"start":1,"format":"decimal","text":"%4.","jc":"left","pstyle":null,"paragraphProperty":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"keepNext":false,"keepLines":false,"pageBreakBefore":false,"windowControl":false,"divId":null},"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"suffix":"tab"}]}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,6 +167,26 @@ impl Paragraph {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn keep_next(mut self, v: bool) -> Self {
|
||||||
|
self.property = self.property.keep_next(v);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn keep_lines(mut self, v: bool) -> Self {
|
||||||
|
self.property = self.property.keep_lines(v);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page_break_before(mut self, v: bool) -> Self {
|
||||||
|
self.property = self.property.page_break_before(v);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn window_control(mut self, v: bool) -> Self {
|
||||||
|
self.property = self.property.window_control(v);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn indent(
|
pub fn indent(
|
||||||
mut self,
|
mut self,
|
||||||
left: Option<i32>,
|
left: Option<i32>,
|
||||||
|
@ -305,7 +325,7 @@ mod tests {
|
||||||
let p = Paragraph::new().add_run(run);
|
let p = Paragraph::new().add_run(run);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serde_json::to_string(&p).unwrap(),
|
serde_json::to_string(&p).unwrap(),
|
||||||
r#"{"id":"12345678","children":[{"type":"run","data":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"children":[{"type":"text","data":{"preserveSpace":true,"text":"Hello"}}]}}],"property":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"divId":null},"hasNumbering":false}"#
|
r#"{"id":"12345678","children":[{"type":"run","data":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"children":[{"type":"text","data":{"preserveSpace":true,"text":"Hello"}}]}}],"property":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"keepNext":false,"keepLines":false,"pageBreakBefore":false,"windowControl":false,"divId":null},"hasNumbering":false}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +336,7 @@ mod tests {
|
||||||
let p = Paragraph::new().add_insert(ins);
|
let p = Paragraph::new().add_insert(ins);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serde_json::to_string(&p).unwrap(),
|
serde_json::to_string(&p).unwrap(),
|
||||||
r#"{"id":"12345678","children":[{"type":"insert","data":{"children":[{"type":"run","data":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"children":[{"type":"text","data":{"preserveSpace":true,"text":"Hello"}}]}}],"author":"unnamed","date":"1970-01-01T00:00:00Z"}}],"property":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"divId":null},"hasNumbering":false}"#
|
r#"{"id":"12345678","children":[{"type":"insert","data":{"children":[{"type":"run","data":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"children":[{"type":"text","data":{"preserveSpace":true,"text":"Hello"}}]}}],"author":"unnamed","date":"1970-01-01T00:00:00Z"}}],"property":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"keepNext":false,"keepLines":false,"pageBreakBefore":false,"windowControl":false,"divId":null},"hasNumbering":false}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,10 @@ pub struct ParagraphProperty {
|
||||||
pub alignment: Option<Justification>,
|
pub alignment: Option<Justification>,
|
||||||
pub indent: Option<Indent>,
|
pub indent: Option<Indent>,
|
||||||
pub line_height: Option<u32>,
|
pub line_height: Option<u32>,
|
||||||
|
pub keep_next: bool,
|
||||||
|
pub keep_lines: bool,
|
||||||
|
pub page_break_before: bool,
|
||||||
|
pub window_control: bool,
|
||||||
// read only
|
// read only
|
||||||
pub(crate) div_id: Option<String>,
|
pub(crate) div_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -27,6 +31,10 @@ impl Default for ParagraphProperty {
|
||||||
alignment: None,
|
alignment: None,
|
||||||
indent: None,
|
indent: None,
|
||||||
line_height: None,
|
line_height: None,
|
||||||
|
keep_next: false,
|
||||||
|
keep_lines: false,
|
||||||
|
page_break_before: false,
|
||||||
|
window_control: false,
|
||||||
div_id: None,
|
div_id: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +81,26 @@ impl ParagraphProperty {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn keep_next(mut self, v: bool) -> Self {
|
||||||
|
self.keep_next = v;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn keep_lines(mut self, v: bool) -> Self {
|
||||||
|
self.keep_lines = v;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page_break_before(mut self, v: bool) -> Self {
|
||||||
|
self.page_break_before = v;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn window_control(mut self, v: bool) -> Self {
|
||||||
|
self.window_control = v;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn hanging_chars(mut self, chars: i32) -> Self {
|
pub(crate) fn hanging_chars(mut self, chars: i32) -> Self {
|
||||||
if let Some(indent) = self.indent {
|
if let Some(indent) = self.indent {
|
||||||
self.indent = Some(indent.hanging_chars(chars));
|
self.indent = Some(indent.hanging_chars(chars));
|
||||||
|
@ -95,16 +123,32 @@ impl BuildXML for ParagraphProperty {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
XMLBuilder::new()
|
let mut b = XMLBuilder::new()
|
||||||
.open_paragraph_property()
|
.open_paragraph_property()
|
||||||
.add_child(&self.run_property)
|
.add_child(&self.run_property)
|
||||||
.add_optional_child(&self.style)
|
.add_optional_child(&self.style)
|
||||||
.add_optional_child(&self.numbering_property)
|
.add_optional_child(&self.numbering_property)
|
||||||
.add_optional_child(&self.alignment)
|
.add_optional_child(&self.alignment)
|
||||||
.add_optional_child(&self.indent)
|
.add_optional_child(&self.indent)
|
||||||
.add_optional_child(&spacing)
|
.add_optional_child(&spacing);
|
||||||
.close()
|
|
||||||
.build()
|
if self.keep_next {
|
||||||
|
b = b.keep_next()
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.keep_lines {
|
||||||
|
b = b.keep_lines()
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.page_break_before {
|
||||||
|
b = b.page_break_before()
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.window_control {
|
||||||
|
b = b.window_control()
|
||||||
|
}
|
||||||
|
|
||||||
|
b.close().build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,13 +187,24 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_keep_next() {
|
||||||
|
let c = ParagraphProperty::new();
|
||||||
|
let b = c.keep_next(true).build();
|
||||||
|
assert_eq!(
|
||||||
|
str::from_utf8(&b).unwrap(),
|
||||||
|
r#"<w:pPr><w:rPr /><w:keepNext />
|
||||||
|
</w:pPr>"#
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_indent_json() {
|
fn test_indent_json() {
|
||||||
let c = ParagraphProperty::new();
|
let c = ParagraphProperty::new();
|
||||||
let b = c.indent(Some(20), Some(SpecialIndentType::FirstLine(10)), None, None);
|
let b = c.indent(Some(20), Some(SpecialIndentType::FirstLine(10)), None, None);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serde_json::to_string(&b).unwrap(),
|
serde_json::to_string(&b).unwrap(),
|
||||||
r#"{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":{"start":20,"startChars":null,"end":null,"specialIndent":{"type":"firstLine","val":10},"hangingChars":null,"firstLineChars":null},"lineHeight":null,"divId":null}"#
|
r#"{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":{"start":20,"startChars":null,"end":null,"specialIndent":{"type":"firstLine","val":10},"hangingChars":null,"firstLineChars":null},"lineHeight":null,"keepNext":false,"keepLines":false,"pageBreakBefore":false,"windowControl":false,"divId":null}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ mod tests {
|
||||||
.grid_span(2);
|
.grid_span(2);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serde_json::to_string(&c).unwrap(),
|
serde_json::to_string(&c).unwrap(),
|
||||||
r#"{"children":[{"type":"paragraph","data":{"id":"12345678","children":[{"type":"run","data":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"children":[{"type":"text","data":{"preserveSpace":true,"text":"Hello"}}]}}],"property":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"divId":null},"hasNumbering":false}}],"property":{"width":null,"borders":null,"gridSpan":2,"verticalMerge":null,"verticalAlign":null,"textDirection":null,"shading":null},"hasNumbering":false}"#
|
r#"{"children":[{"type":"paragraph","data":{"id":"12345678","children":[{"type":"run","data":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"children":[{"type":"text","data":{"preserveSpace":true,"text":"Hello"}}]}}],"property":{"runProperty":{"sz":null,"szCs":null,"color":null,"highlight":null,"underline":null,"bold":null,"boldCs":null,"italic":null,"italicCs":null,"vanish":null,"spacing":null,"fonts":null,"textBorder":null},"style":null,"numberingProperty":null,"alignment":null,"indent":null,"lineHeight":null,"keepNext":false,"keepLines":false,"pageBreakBefore":false,"windowControl":false,"divId":null},"hasNumbering":false}}],"property":{"width":null,"borders":null,"gridSpan":2,"verticalMerge":null,"verticalAlign":null,"textDirection":null,"shading":null},"hasNumbering":false}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,18 @@ impl ElementReader for Paragraph {
|
||||||
p = p.run_property(run_pr);
|
p = p.run_property(run_pr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
XMLElement::KeepNext => {
|
||||||
|
p.property.keep_next = true;
|
||||||
|
}
|
||||||
|
XMLElement::KeepLines => {
|
||||||
|
p.property.keep_lines = true;
|
||||||
|
}
|
||||||
|
XMLElement::PageBreakBefore => {
|
||||||
|
p.property.page_break_before = true;
|
||||||
|
}
|
||||||
|
XMLElement::WindowControl => {
|
||||||
|
p.property.window_control = true;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ pub enum XMLElement {
|
||||||
NumberingId,
|
NumberingId,
|
||||||
Justification,
|
Justification,
|
||||||
Insert,
|
Insert,
|
||||||
|
KeepNext,
|
||||||
|
KeepLines,
|
||||||
|
PageBreakBefore,
|
||||||
|
WindowControl,
|
||||||
DivId,
|
DivId,
|
||||||
Div,
|
Div,
|
||||||
DivsChild,
|
DivsChild,
|
||||||
|
@ -310,6 +314,10 @@ impl FromStr for XMLElement {
|
||||||
"marTop" => Ok(XMLElement::MarginTop),
|
"marTop" => Ok(XMLElement::MarginTop),
|
||||||
"marBottom" => Ok(XMLElement::MarginBottom),
|
"marBottom" => Ok(XMLElement::MarginBottom),
|
||||||
"webSettings" => Ok(XMLElement::WebSettings),
|
"webSettings" => Ok(XMLElement::WebSettings),
|
||||||
|
"keepNext" => Ok(XMLElement::KeepNext),
|
||||||
|
"keepLines" => Ok(XMLElement::KeepLines),
|
||||||
|
"pageBreakBefore" => Ok(XMLElement::PageBreakBefore),
|
||||||
|
"windowControl" => Ok(XMLElement::WindowControl),
|
||||||
_ => Ok(XMLElement::Unsupported),
|
_ => Ok(XMLElement::Unsupported),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,6 +309,11 @@ impl XMLBuilder {
|
||||||
"w:val"
|
"w:val"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
closed!(keep_next, "w:keepNext");
|
||||||
|
closed!(keep_lines, "w:keepLines");
|
||||||
|
closed!(page_break_before, "w:pageBreakBefore");
|
||||||
|
closed!(window_control, "w:windowControl");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<w:lvlOverride w:ilvl="0">
|
<w:lvlOverride w:ilvl="0">
|
||||||
<w:startOverride w:val="1"/>
|
<w:startOverride w:val="1"/>
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -399,6 +399,22 @@ export class Docx {
|
||||||
paragraph = paragraph.fonts(f);
|
paragraph = paragraph.fonts(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p.property.keepLines) {
|
||||||
|
paragraph = paragraph.keep_lines(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.property.keepNext) {
|
||||||
|
paragraph = paragraph.keep_next(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.property.pageBreakBefore) {
|
||||||
|
paragraph = paragraph.page_break_before(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.property.windowControl) {
|
||||||
|
paragraph = paragraph.window_control(true);
|
||||||
|
}
|
||||||
|
|
||||||
return paragraph;
|
return paragraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,10 @@ export type ParagraphPropertyJSON = {
|
||||||
indent: IndentJSON | null;
|
indent: IndentJSON | null;
|
||||||
lineHeight: number | null;
|
lineHeight: number | null;
|
||||||
divId: string | null;
|
divId: string | null;
|
||||||
|
keepNext: boolean;
|
||||||
|
keepLines: boolean;
|
||||||
|
pageBreakBefore: boolean;
|
||||||
|
windowControl: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ParagraphJSON = {
|
export type ParagraphJSON = {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import { LevelJSON } from "./json";
|
import { LevelJSON } from "./json";
|
||||||
import { ParagraphProperty, SpecialIndentKind } from "./paragraph";
|
import {
|
||||||
|
createDefaultParagraphProperty,
|
||||||
|
ParagraphProperty,
|
||||||
|
SpecialIndentKind,
|
||||||
|
} from "./paragraph";
|
||||||
import { RunFonts, RunProperty } from "./run";
|
import { RunFonts, RunProperty } from "./run";
|
||||||
|
|
||||||
export type LevelSuffixType = "nothing" | "tab" | "space";
|
export type LevelSuffixType = "nothing" | "tab" | "space";
|
||||||
|
@ -10,7 +14,7 @@ export class Level {
|
||||||
format: string;
|
format: string;
|
||||||
text: string;
|
text: string;
|
||||||
jc: string;
|
jc: string;
|
||||||
paragraphProperty: ParagraphProperty = { runProperty: {} };
|
paragraphProperty: ParagraphProperty = createDefaultParagraphProperty();
|
||||||
runProperty: RunProperty = {};
|
runProperty: RunProperty = {};
|
||||||
levelSuffix: LevelSuffixType;
|
levelSuffix: LevelSuffixType;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Run, RunProperty, RunFonts } from "./run";
|
import { Run, RunProperty, RunFonts, createDefaultRunProperty } from "./run";
|
||||||
import { Insert } from "./insert";
|
import { Insert } from "./insert";
|
||||||
import { Delete } from "./delete";
|
import { Delete } from "./delete";
|
||||||
import { BookmarkStart } from "./bookmark-start";
|
import { BookmarkStart } from "./bookmark-start";
|
||||||
|
@ -40,14 +40,26 @@ export type ParagraphProperty = {
|
||||||
};
|
};
|
||||||
lineHeight?: number;
|
lineHeight?: number;
|
||||||
runProperty: RunProperty;
|
runProperty: RunProperty;
|
||||||
|
keepNext: boolean;
|
||||||
|
keepLines: boolean;
|
||||||
|
pageBreakBefore: boolean;
|
||||||
|
windowControl: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createDefaultParagraphProperty = (): ParagraphProperty => {
|
||||||
|
return {
|
||||||
|
runProperty: createDefaultRunProperty(),
|
||||||
|
keepNext: false,
|
||||||
|
keepLines: false,
|
||||||
|
pageBreakBefore: false,
|
||||||
|
windowControl: false,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Paragraph {
|
export class Paragraph {
|
||||||
hasNumberings = false;
|
hasNumberings = false;
|
||||||
children: ParagraphChild[] = [];
|
children: ParagraphChild[] = [];
|
||||||
property: ParagraphProperty = {
|
property: ParagraphProperty = createDefaultParagraphProperty();
|
||||||
runProperty: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
addRun(run: Run) {
|
addRun(run: Run) {
|
||||||
this.children.push(run);
|
this.children.push(run);
|
||||||
|
@ -114,6 +126,26 @@ export class Paragraph {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keepNext(v: boolean) {
|
||||||
|
this.property = { ...this.property, keepNext: v };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
keepLines(v: boolean) {
|
||||||
|
this.property = { ...this.property, keepLines: v };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
pageBreakBefore(v: boolean) {
|
||||||
|
this.property = { ...this.property, pageBreakBefore: v };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
windowControl(v: boolean) {
|
||||||
|
this.property = { ...this.property, windowControl: v };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// run property
|
// run property
|
||||||
size(size: number) {
|
size(size: number) {
|
||||||
this.property.runProperty = { ...this.property.runProperty, size };
|
this.property.runProperty = { ...this.property.runProperty, size };
|
||||||
|
|
|
@ -26,6 +26,10 @@ export type RunProperty = {
|
||||||
textBorder?: TextBorder;
|
textBorder?: TextBorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const createDefaultRunProperty = (): RunProperty => {
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
export class RunFonts {
|
export class RunFonts {
|
||||||
_ascii?: string;
|
_ascii?: string;
|
||||||
_hiAnsi?: string;
|
_hiAnsi?: string;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { RunProperty } from "./run";
|
import { RunProperty, createDefaultRunProperty } from "./run";
|
||||||
import { ParagraphProperty } from "./paragraph";
|
import { createDefaultParagraphProperty, ParagraphProperty } from "./paragraph";
|
||||||
import { TableProperty } from "./table";
|
import { TableProperty } from "./table";
|
||||||
|
|
||||||
export type StyleType =
|
export type StyleType =
|
||||||
|
@ -22,8 +22,8 @@ export class Style {
|
||||||
this._styleId = id;
|
this._styleId = id;
|
||||||
this._styleType = type;
|
this._styleType = type;
|
||||||
this._name = "";
|
this._name = "";
|
||||||
this._runProperty = {};
|
this._runProperty = createDefaultRunProperty();
|
||||||
this._paragraphProperty = { runProperty: {} };
|
this._paragraphProperty = createDefaultParagraphProperty();
|
||||||
this._tableProperty = {};
|
this._tableProperty = {};
|
||||||
this._basedOn = null;
|
this._basedOn = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "docx-wasm",
|
"name": "docx-wasm",
|
||||||
"version": "0.0.189",
|
"version": "0.0.190",
|
||||||
"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>",
|
||||||
|
|
|
@ -116,6 +116,26 @@ impl Paragraph {
|
||||||
self.0 = self.0.line_height(line_height);
|
self.0 = self.0.line_height(line_height);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn keep_next(mut self, v: bool) -> Self {
|
||||||
|
self.0 = self.0.keep_next(v);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn keep_lines(mut self, v: bool) -> Self {
|
||||||
|
self.0 = self.0.keep_lines(v);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page_break_before(mut self, v: bool) -> Self {
|
||||||
|
self.0 = self.0.page_break_before(v);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn window_control(mut self, v: bool) -> Self {
|
||||||
|
self.0 = self.0.window_control(v);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Paragraph {
|
impl Paragraph {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue