refactor: rename macros (#25)
* refactor: rename macros * fix: some clippy error * fix: lint error * chore: run lint in actionsmain
parent
a10441cbdf
commit
22aee045a0
|
@ -63,18 +63,18 @@ jobs:
|
||||||
path: ~/.cargo/git
|
path: ~/.cargo/git
|
||||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||||
- run: cargo build
|
- run: cargo build
|
||||||
# clippy:
|
lint:
|
||||||
# name: Clippy
|
name: Clippy
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
# - uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
# with:
|
with:
|
||||||
# profile: minimal
|
profile: minimal
|
||||||
# toolchain: stable
|
toolchain: stable
|
||||||
# override: true
|
override: true
|
||||||
# - run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
# - uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
# with:
|
with:
|
||||||
# command: clippy
|
command: clippy
|
||||||
# args: -- -D warnings
|
args: -- -D warnings
|
||||||
|
|
|
@ -6,6 +6,12 @@ pub struct ContentTypes {}
|
||||||
|
|
||||||
impl ContentTypes {
|
impl ContentTypes {
|
||||||
pub fn new() -> ContentTypes {
|
pub fn new() -> ContentTypes {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ContentTypes {
|
||||||
|
fn default() -> Self {
|
||||||
ContentTypes {}
|
ContentTypes {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,13 @@ pub struct AppProps {}
|
||||||
|
|
||||||
impl AppProps {
|
impl AppProps {
|
||||||
pub fn new() -> AppProps {
|
pub fn new() -> AppProps {
|
||||||
AppProps {}
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for AppProps {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,30 @@ pub struct CorePropsConfig {
|
||||||
title: Option<String>,
|
title: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for CorePropsConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
created: None,
|
||||||
|
creator: None,
|
||||||
|
description: None,
|
||||||
|
language: None,
|
||||||
|
last_modified_by: None,
|
||||||
|
modified: None,
|
||||||
|
revision: None,
|
||||||
|
subject: None,
|
||||||
|
title: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for CoreProps {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
config: CorePropsConfig::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CoreProps {
|
impl CoreProps {
|
||||||
pub(crate) fn new(config: CorePropsConfig) -> CoreProps {
|
pub(crate) fn new(config: CorePropsConfig) -> CoreProps {
|
||||||
CoreProps { config }
|
CoreProps { config }
|
||||||
|
|
|
@ -9,7 +9,13 @@ pub struct DocumentRels {
|
||||||
|
|
||||||
impl DocumentRels {
|
impl DocumentRels {
|
||||||
pub fn new() -> DocumentRels {
|
pub fn new() -> DocumentRels {
|
||||||
DocumentRels {
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for DocumentRels {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
has_comments: false,
|
has_comments: false,
|
||||||
has_numberings: false,
|
has_numberings: false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,13 @@ pub struct Bold {}
|
||||||
|
|
||||||
impl Bold {
|
impl Bold {
|
||||||
pub fn new() -> Bold {
|
pub fn new() -> Bold {
|
||||||
Bold {}
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Bold {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,13 @@ pub struct BoldCs {}
|
||||||
|
|
||||||
impl BoldCs {
|
impl BoldCs {
|
||||||
pub fn new() -> BoldCs {
|
pub fn new() -> BoldCs {
|
||||||
BoldCs {}
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for BoldCs {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,12 @@ pub struct DocDefaults {
|
||||||
|
|
||||||
impl DocDefaults {
|
impl DocDefaults {
|
||||||
pub fn new() -> DocDefaults {
|
pub fn new() -> DocDefaults {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for DocDefaults {
|
||||||
|
fn default() -> Self {
|
||||||
let run_property_default = RunPropertyDefault::new();
|
let run_property_default = RunPropertyDefault::new();
|
||||||
DocDefaults {
|
DocDefaults {
|
||||||
run_property_default,
|
run_property_default,
|
||||||
|
|
|
@ -6,7 +6,13 @@ pub struct Italic {}
|
||||||
|
|
||||||
impl Italic {
|
impl Italic {
|
||||||
pub fn new() -> Italic {
|
pub fn new() -> Italic {
|
||||||
Italic {}
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Italic {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,13 @@ pub struct ItalicCs {}
|
||||||
|
|
||||||
impl ItalicCs {
|
impl ItalicCs {
|
||||||
pub fn new() -> ItalicCs {
|
pub fn new() -> ItalicCs {
|
||||||
ItalicCs {}
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ItalicCs {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub enum ParagraphChild {
|
||||||
Delete(Delete),
|
Delete(Delete),
|
||||||
BookmarkStart(BookmarkStart),
|
BookmarkStart(BookmarkStart),
|
||||||
BookmarkEnd(BookmarkEnd),
|
BookmarkEnd(BookmarkEnd),
|
||||||
CommentStart(CommentRangeStart),
|
CommentStart(Box<CommentRangeStart>),
|
||||||
CommentEnd(CommentRangeEnd),
|
CommentEnd(CommentRangeEnd),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +93,9 @@ impl Paragraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_comment_start(mut self, comment: Comment) -> Paragraph {
|
pub fn add_comment_start(mut self, comment: Comment) -> Paragraph {
|
||||||
self.children
|
self.children.push(ParagraphChild::CommentStart(Box::new(
|
||||||
.push(ParagraphChild::CommentStart(CommentRangeStart::new(
|
CommentRangeStart::new(comment),
|
||||||
comment,
|
)));
|
||||||
)));
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,13 @@ pub struct QFormat {}
|
||||||
|
|
||||||
impl QFormat {
|
impl QFormat {
|
||||||
pub fn new() -> QFormat {
|
pub fn new() -> QFormat {
|
||||||
QFormat {}
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for QFormat {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,12 @@ pub struct RunPropertyDefault {
|
||||||
|
|
||||||
impl RunPropertyDefault {
|
impl RunPropertyDefault {
|
||||||
pub fn new() -> RunPropertyDefault {
|
pub fn new() -> RunPropertyDefault {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for RunPropertyDefault {
|
||||||
|
fn default() -> Self {
|
||||||
let run_property = RunProperty::new();
|
let run_property = RunProperty::new();
|
||||||
RunPropertyDefault { run_property }
|
RunPropertyDefault { run_property }
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@ pub struct Tab {}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
pub fn new() -> Tab {
|
pub fn new() -> Tab {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Tab {
|
||||||
|
fn default() -> Self {
|
||||||
Tab {}
|
Tab {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,7 @@ pub enum TableCellContent {
|
||||||
|
|
||||||
impl TableCell {
|
impl TableCell {
|
||||||
pub fn new() -> TableCell {
|
pub fn new() -> TableCell {
|
||||||
let property = TableCellProperty::new();
|
Default::default()
|
||||||
let contents = vec![];
|
|
||||||
Self {
|
|
||||||
property,
|
|
||||||
contents,
|
|
||||||
has_numbering: false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_paragraph(mut self, p: Paragraph) -> TableCell {
|
pub fn add_paragraph(mut self, p: Paragraph) -> TableCell {
|
||||||
|
@ -50,6 +44,18 @@ impl TableCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for TableCell {
|
||||||
|
fn default() -> Self {
|
||||||
|
let property = TableCellProperty::new();
|
||||||
|
let contents = vec![];
|
||||||
|
Self {
|
||||||
|
property,
|
||||||
|
contents,
|
||||||
|
has_numbering: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BuildXML for TableCell {
|
impl BuildXML for TableCell {
|
||||||
fn build(&self) -> Vec<u8> {
|
fn build(&self) -> Vec<u8> {
|
||||||
let b = XMLBuilder::new();
|
let b = XMLBuilder::new();
|
||||||
|
|
|
@ -13,12 +13,7 @@ pub struct TableCellProperty {
|
||||||
|
|
||||||
impl TableCellProperty {
|
impl TableCellProperty {
|
||||||
pub fn new() -> TableCellProperty {
|
pub fn new() -> TableCellProperty {
|
||||||
TableCellProperty {
|
Default::default()
|
||||||
width: None,
|
|
||||||
borders: None,
|
|
||||||
grid_span: None,
|
|
||||||
vertical_merge: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn width(mut self, v: usize, t: WidthType) -> TableCellProperty {
|
pub fn width(mut self, v: usize, t: WidthType) -> TableCellProperty {
|
||||||
|
@ -37,6 +32,17 @@ impl TableCellProperty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for TableCellProperty {
|
||||||
|
fn default() -> Self {
|
||||||
|
TableCellProperty {
|
||||||
|
width: None,
|
||||||
|
borders: None,
|
||||||
|
grid_span: None,
|
||||||
|
vertical_merge: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BuildXML for TableCellProperty {
|
impl BuildXML for TableCellProperty {
|
||||||
fn build(&self) -> Vec<u8> {
|
fn build(&self) -> Vec<u8> {
|
||||||
XMLBuilder::new()
|
XMLBuilder::new()
|
||||||
|
|
|
@ -6,6 +6,12 @@ pub struct TableRowProperty {}
|
||||||
|
|
||||||
impl TableRowProperty {
|
impl TableRowProperty {
|
||||||
pub fn new() -> TableRowProperty {
|
pub fn new() -> TableRowProperty {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for TableRowProperty {
|
||||||
|
fn default() -> Self {
|
||||||
TableRowProperty {}
|
TableRowProperty {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,12 @@ impl Vanish {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Vanish {
|
||||||
|
fn default() -> Self {
|
||||||
|
Vanish {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BuildXML for Vanish {
|
impl BuildXML for Vanish {
|
||||||
fn build(&self) -> Vec<u8> {
|
fn build(&self) -> Vec<u8> {
|
||||||
let b = XMLBuilder::new();
|
let b = XMLBuilder::new();
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#[allow(unused)]
|
#[cfg(not(test))]
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
#[cfg(not(test))]
|
||||||
#[allow(dead_code)]
|
|
||||||
static HISTORY_ID: AtomicUsize = AtomicUsize::new(0);
|
static HISTORY_ID: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
pub trait HistoryId {
|
pub trait HistoryId {
|
||||||
fn generate(&self) -> String {
|
fn generate(&self) -> String {
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
let id = HISTORY_ID.load(Ordering::Relaxed);
|
let id = HISTORY_ID.load(Ordering::Relaxed);
|
||||||
HISTORY_ID.store(id + 1, Ordering::Relaxed);
|
HISTORY_ID.store(id + 1, Ordering::Relaxed);
|
||||||
format!("{}", id)
|
format!("{}", id)
|
||||||
|
|
|
@ -133,11 +133,8 @@ impl Docx {
|
||||||
match child {
|
match child {
|
||||||
DocumentChild::Paragraph(paragraph) => {
|
DocumentChild::Paragraph(paragraph) => {
|
||||||
for child in ¶graph.children {
|
for child in ¶graph.children {
|
||||||
match child {
|
if let ParagraphChild::CommentStart(c) = child {
|
||||||
ParagraphChild::CommentStart(c) => {
|
comments.push(c.comment());
|
||||||
comments.push(c.comment());
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,11 +145,8 @@ impl Docx {
|
||||||
match content {
|
match content {
|
||||||
TableCellContent::Paragraph(paragraph) => {
|
TableCellContent::Paragraph(paragraph) => {
|
||||||
for child in ¶graph.children {
|
for child in ¶graph.children {
|
||||||
match child {
|
if let ParagraphChild::CommentStart(c) = child {
|
||||||
ParagraphChild::CommentStart(c) => {
|
comments.push(c.comment());
|
||||||
comments.push(c.comment());
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +159,7 @@ impl Docx {
|
||||||
}
|
}
|
||||||
// If this document has comments, set comments.xml to document_rels.
|
// If this document has comments, set comments.xml to document_rels.
|
||||||
// This is because comments.xml without comment cause an error on word online.
|
// This is because comments.xml without comment cause an error on word online.
|
||||||
if comments.len() > 0 {
|
if !comments.is_empty() {
|
||||||
self.document_rels.has_comments = true;
|
self.document_rels.has_comments = true;
|
||||||
}
|
}
|
||||||
self.comments.add_comments(comments);
|
self.comments.add_comments(comments);
|
||||||
|
|
|
@ -6,6 +6,12 @@ pub struct Rels {}
|
||||||
|
|
||||||
impl Rels {
|
impl Rels {
|
||||||
pub fn new() -> Rels {
|
pub fn new() -> Rels {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Rels {
|
||||||
|
fn default() -> Self {
|
||||||
Rels {}
|
Rels {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,12 +30,12 @@ impl BuildXML for Rels {
|
||||||
"rId2",
|
"rId2",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
|
||||||
"docProps/app.xml"
|
"docProps/app.xml"
|
||||||
)
|
)
|
||||||
.relationship(
|
.relationship(
|
||||||
"rId3",
|
"rId3",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
||||||
"word/document.xml"
|
"word/document.xml"
|
||||||
)
|
)
|
||||||
.close()
|
.close()
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
@ -39,9 +45,9 @@ impl BuildXML for Rels {
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::str;
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
use std::str;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_build() {
|
fn test_build() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{DefaultTabStop, Style, Zoom};
|
use super::{DefaultTabStop, Zoom};
|
||||||
use crate::documents::BuildXML;
|
use crate::documents::BuildXML;
|
||||||
use crate::xml_builder::*;
|
use crate::xml_builder::*;
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,4 @@ mod zipper;
|
||||||
|
|
||||||
pub use documents::*;
|
pub use documents::*;
|
||||||
pub use errors::*;
|
pub use errors::*;
|
||||||
pub(crate) use escape::*;
|
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use super::XmlEvent;
|
||||||
|
|
||||||
impl XMLBuilder {
|
impl XMLBuilder {
|
||||||
// i.e. <cp:properties xmlns:vt="http://schemas.openxmlformats.org/package/2006/relationships">
|
// i.e. <cp:properties xmlns:vt="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||||
opened_el!(
|
open!(
|
||||||
open_core_properties,
|
open_core_properties,
|
||||||
"cp:coreProperties",
|
"cp:coreProperties",
|
||||||
"xmlns:cp",
|
"xmlns:cp",
|
||||||
|
@ -12,13 +12,13 @@ impl XMLBuilder {
|
||||||
"xmlns:dcmitype",
|
"xmlns:dcmitype",
|
||||||
"xmlns:xsi"
|
"xmlns:xsi"
|
||||||
);
|
);
|
||||||
closed_el_with_child!(dcterms_created, "dcterms:created", "xsi:type");
|
closed_with_child!(dcterms_created, "dcterms:created", "xsi:type");
|
||||||
closed_el_with_child!(dc_creator, "dc:creator");
|
closed_with_child!(dc_creator, "dc:creator");
|
||||||
closed_el_with_child!(dc_description, "dc:description");
|
closed_with_child!(dc_description, "dc:description");
|
||||||
closed_el_with_child!(dc_language, "dc:language");
|
closed_with_child!(dc_language, "dc:language");
|
||||||
closed_el_with_child!(cp_last_modified_by, "cp:lastModifiedBy");
|
closed_with_child!(cp_last_modified_by, "cp:lastModifiedBy");
|
||||||
closed_el_with_child!(dcterms_modified, "dcterms:modified", "xsi:type");
|
closed_with_child!(dcterms_modified, "dcterms:modified", "xsi:type");
|
||||||
closed_el_with_child!(cp_revision, "cp:revision");
|
closed_with_child!(cp_revision, "cp:revision");
|
||||||
closed_el_with_child!(dc_subject, "dc:subject");
|
closed_with_child!(dc_subject, "dc:subject");
|
||||||
closed_el_with_child!(dc_title, "dc:title");
|
closed_with_child!(dc_title, "dc:title");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ const EXPECT_MESSAGE: &str = "should write buf";
|
||||||
|
|
||||||
impl XMLBuilder {
|
impl XMLBuilder {
|
||||||
// i.e. <w:body... >
|
// i.e. <w:body... >
|
||||||
opened_el!(open_body, "w:body");
|
open!(open_body, "w:body");
|
||||||
// i.e. <w:basedOn ... >
|
// i.e. <w:basedOn ... >
|
||||||
only_str_val_el!(based_on, "w:basedOn");
|
closed_with_str!(based_on, "w:basedOn");
|
||||||
// i.e. <w:t ... >
|
// i.e. <w:t ... >
|
||||||
pub(crate) fn text(mut self, text: &str, preserve_space: bool) -> Self {
|
pub(crate) fn text(mut self, text: &str, preserve_space: bool) -> Self {
|
||||||
let space = if preserve_space {
|
let space = if preserve_space {
|
||||||
|
@ -36,32 +36,32 @@ impl XMLBuilder {
|
||||||
self.close()
|
self.close()
|
||||||
}
|
}
|
||||||
// i.e. <w:r ... >
|
// i.e. <w:r ... >
|
||||||
opened_el!(open_run, "w:r");
|
open!(open_run, "w:r");
|
||||||
opened_el!(open_run_property, "w:rPr");
|
open!(open_run_property, "w:rPr");
|
||||||
opened_el!(open_run_property_default, "w:rPrDefault");
|
open!(open_run_property_default, "w:rPrDefault");
|
||||||
// i.e. <w:qFormat ... >
|
// i.e. <w:qFormat ... >
|
||||||
closed_el!(q_format, "w:qFormat");
|
closed!(q_format, "w:qFormat");
|
||||||
// i.e. <w:p ... >
|
// i.e. <w:p ... >
|
||||||
// opened_el!(open_paragraph, "w:p");
|
// open!(open_paragraph, "w:p");
|
||||||
opened_el_with_attrs!(open_paragraph, "w:p");
|
open_with_attrs!(open_paragraph, "w:p");
|
||||||
opened_el!(open_paragraph_property, "w:pPr");
|
open!(open_paragraph_property, "w:pPr");
|
||||||
opened_el!(open_doc_defaults, "w:docDefaults");
|
open!(open_doc_defaults, "w:docDefaults");
|
||||||
// i.e. <w:name ... >
|
// i.e. <w:name ... >
|
||||||
only_str_val_el!(name, "w:name");
|
closed_with_str!(name, "w:name");
|
||||||
// i.e. <w:jc ... >
|
// i.e. <w:jc ... >
|
||||||
only_str_val_el!(justification, "w:jc");
|
closed_with_str!(justification, "w:jc");
|
||||||
// i.e. <w:pStyle ... >
|
// i.e. <w:pStyle ... >
|
||||||
only_str_val_el!(paragraph_style, "w:pStyle");
|
closed_with_str!(paragraph_style, "w:pStyle");
|
||||||
// i.e. <w:sz ... >
|
// i.e. <w:sz ... >
|
||||||
only_usize_val_el!(sz, "w:sz");
|
closed_with_usize!(sz, "w:sz");
|
||||||
// i.e. <w:szCs ... >
|
// i.e. <w:szCs ... >
|
||||||
only_usize_val_el!(sz_cs, "w:szCs");
|
closed_with_usize!(sz_cs, "w:szCs");
|
||||||
|
|
||||||
closed_el!(b, "w:b");
|
closed!(b, "w:b");
|
||||||
closed_el!(b_cs, "w:bCs");
|
closed!(b_cs, "w:bCs");
|
||||||
|
|
||||||
closed_el!(i, "w:i");
|
closed!(i, "w:i");
|
||||||
closed_el!(i_cs, "w:iCs");
|
closed!(i_cs, "w:iCs");
|
||||||
// Build w:style element
|
// Build w:style element
|
||||||
// i.e. <w:style ... >
|
// i.e. <w:style ... >
|
||||||
pub(crate) fn open_style(mut self, style_type: StyleType, id: &str) -> Self {
|
pub(crate) fn open_style(mut self, style_type: StyleType, id: &str) -> Self {
|
||||||
|
@ -75,16 +75,16 @@ impl XMLBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
// i.e. <w:next ... >
|
// i.e. <w:next ... >
|
||||||
only_str_val_el!(next, "w:next");
|
closed_with_str!(next, "w:next");
|
||||||
|
|
||||||
// i.e. <w:color ... >
|
// i.e. <w:color ... >
|
||||||
only_str_val_el!(color, "w:color");
|
closed_with_str!(color, "w:color");
|
||||||
|
|
||||||
// i.e. <w:highlight ... >
|
// i.e. <w:highlight ... >
|
||||||
only_str_val_el!(highlight, "w:highlight");
|
closed_with_str!(highlight, "w:highlight");
|
||||||
|
|
||||||
// i.e. <w:u ... >
|
// i.e. <w:u ... >
|
||||||
only_str_val_el!(underline, "w:u");
|
closed_with_str!(underline, "w:u");
|
||||||
|
|
||||||
// i.e. <w:ind ... >
|
// i.e. <w:ind ... >
|
||||||
pub(crate) fn indent(mut self, left: usize, special_indent: Option<SpecialIndentType>) -> Self {
|
pub(crate) fn indent(mut self, left: usize, special_indent: Option<SpecialIndentType>) -> Self {
|
||||||
|
@ -107,24 +107,24 @@ impl XMLBuilder {
|
||||||
//
|
//
|
||||||
// Table elements
|
// Table elements
|
||||||
//
|
//
|
||||||
opened_el!(open_table, "w:tbl");
|
open!(open_table, "w:tbl");
|
||||||
opened_el!(open_table_property, "w:tblPr");
|
open!(open_table_property, "w:tblPr");
|
||||||
opened_el!(open_table_grid, "w:tblGrid");
|
open!(open_table_grid, "w:tblGrid");
|
||||||
opened_el!(open_table_row, "w:tr");
|
open!(open_table_row, "w:tr");
|
||||||
opened_el!(open_table_row_property, "w:trPr");
|
open!(open_table_row_property, "w:trPr");
|
||||||
opened_el!(open_table_cell, "w:tc");
|
open!(open_table_cell, "w:tc");
|
||||||
opened_el!(open_table_cell_property, "w:tcPr");
|
open!(open_table_cell_property, "w:tcPr");
|
||||||
opened_el!(open_table_cell_borders, "w:tcBorders");
|
open!(open_table_cell_borders, "w:tcBorders");
|
||||||
opened_el!(open_table_borders, "w:tblBorders");
|
open!(open_table_borders, "w:tblBorders");
|
||||||
opened_el!(open_table_cell_margins, "w:tblCellMar");
|
open!(open_table_cell_margins, "w:tblCellMar");
|
||||||
|
|
||||||
closed_w_with_type_el!(table_width, "w:tblW");
|
closed_w_with_type_el!(table_width, "w:tblW");
|
||||||
closed_w_with_type_el!(table_indent, "w:tblInd");
|
closed_w_with_type_el!(table_indent, "w:tblInd");
|
||||||
closed_w_with_type_el!(grid_column, "w:gridCol");
|
closed_w_with_type_el!(grid_column, "w:gridCol");
|
||||||
closed_w_with_type_el!(table_cell_width, "w:tcW");
|
closed_w_with_type_el!(table_cell_width, "w:tcW");
|
||||||
|
|
||||||
only_usize_val_el!(grid_span, "w:gridSpan");
|
closed_with_usize!(grid_span, "w:gridSpan");
|
||||||
only_str_val_el!(vertical_merge, "w:vMerge");
|
closed_with_str!(vertical_merge, "w:vMerge");
|
||||||
|
|
||||||
closed_w_with_type_el!(margin_top, "w:top");
|
closed_w_with_type_el!(margin_top, "w:top");
|
||||||
closed_w_with_type_el!(margin_left, "w:left");
|
closed_w_with_type_el!(margin_left, "w:left");
|
||||||
|
@ -138,24 +138,24 @@ impl XMLBuilder {
|
||||||
closed_border_el!(border_inside_h, "w:insideH");
|
closed_border_el!(border_inside_h, "w:insideH");
|
||||||
closed_border_el!(border_inside_v, "w:insideV");
|
closed_border_el!(border_inside_v, "w:insideV");
|
||||||
|
|
||||||
closed_el!(shd, "w:shd", "w:fill", "w:val");
|
closed!(shd, "w:shd", "w:fill", "w:val");
|
||||||
|
|
||||||
closed_el!(tab, "w:tab");
|
closed!(tab, "w:tab");
|
||||||
closed_el!(tab_with_pos, "w:tab", "w:val", "w:pos");
|
closed!(tab_with_pos, "w:tab", "w:val", "w:pos");
|
||||||
|
|
||||||
closed_el!(br, "w:br", "w:type");
|
closed!(br, "w:br", "w:type");
|
||||||
closed_el!(zoom, "w:zoom", "w:percent");
|
closed!(zoom, "w:zoom", "w:percent");
|
||||||
only_usize_val_el!(default_tab_stop, "w:defaultTabStop");
|
closed_with_usize!(default_tab_stop, "w:defaultTabStop");
|
||||||
|
|
||||||
opened_el!(open_font, "w:font", "w:name");
|
open!(open_font, "w:font", "w:name");
|
||||||
only_str_val_el!(pitch, "w:pitch");
|
closed_with_str!(pitch, "w:pitch");
|
||||||
only_str_val_el!(family, "w:family");
|
closed_with_str!(family, "w:family");
|
||||||
only_str_val_el!(charset, "w:charset");
|
closed_with_str!(charset, "w:charset");
|
||||||
|
|
||||||
opened_el!(open_section_property, "w:sectPr");
|
open!(open_section_property, "w:sectPr");
|
||||||
only_str_val_el!(type_tag, "w:type");
|
closed_with_str!(type_tag, "w:type");
|
||||||
closed_el!(page_size, "w:pgSz", "w:w", "w:h");
|
closed!(page_size, "w:pgSz", "w:w", "w:h");
|
||||||
closed_el!(
|
closed!(
|
||||||
page_margin,
|
page_margin,
|
||||||
"w:pgMar",
|
"w:pgMar",
|
||||||
"w:top",
|
"w:top",
|
||||||
|
@ -166,19 +166,19 @@ impl XMLBuilder {
|
||||||
"w:footer",
|
"w:footer",
|
||||||
"w:gutter"
|
"w:gutter"
|
||||||
);
|
);
|
||||||
closed_el!(columns, "w:cols", "w:space");
|
closed!(columns, "w:cols", "w:space");
|
||||||
closed_el!(document_grid, "w:docGrid", "w:type", "w:linePitch");
|
closed!(document_grid, "w:docGrid", "w:type", "w:linePitch");
|
||||||
|
|
||||||
opened_el!(open_insert, "w:ins", "w:id", "w:author", "w:date");
|
open!(open_insert, "w:ins", "w:id", "w:author", "w:date");
|
||||||
opened_el!(open_delete, "w:del", "w:id", "w:author", "w:date");
|
open!(open_delete, "w:del", "w:id", "w:author", "w:date");
|
||||||
|
|
||||||
closed_el!(bookmark_start, "w:bookmarkStart", "w:id", "w:name");
|
closed!(bookmark_start, "w:bookmarkStart", "w:id", "w:name");
|
||||||
closed_el!(bookmark_end, "w:bookmarkEnd", "w:id");
|
closed!(bookmark_end, "w:bookmarkEnd", "w:id");
|
||||||
|
|
||||||
closed_el!(comment_range_start, "w:commentRangeStart", "w:id");
|
closed!(comment_range_start, "w:commentRangeStart", "w:id");
|
||||||
closed_el!(comment_range_end, "w:commentRangeEnd", "w:id");
|
closed!(comment_range_end, "w:commentRangeEnd", "w:id");
|
||||||
closed_el!(comment_reference, "w:commentReference", "w:id");
|
closed!(comment_reference, "w:commentReference", "w:id");
|
||||||
opened_el!(
|
open!(
|
||||||
open_comment,
|
open_comment,
|
||||||
"w:comment",
|
"w:comment",
|
||||||
"w:id",
|
"w:id",
|
||||||
|
@ -187,19 +187,19 @@ impl XMLBuilder {
|
||||||
"w:initials"
|
"w:initials"
|
||||||
);
|
);
|
||||||
|
|
||||||
opened_el!(open_abstract_num, "w:abstractNum", "w:abstractNumId");
|
open!(open_abstract_num, "w:abstractNum", "w:abstractNumId");
|
||||||
opened_el!(open_level, "w:lvl", "w:ilvl");
|
open!(open_level, "w:lvl", "w:ilvl");
|
||||||
opened_el!(open_tabs, "w:tabs");
|
open!(open_tabs, "w:tabs");
|
||||||
opened_el!(open_num, "w:num", "w:numId");
|
open!(open_num, "w:num", "w:numId");
|
||||||
opened_el!(open_numbering_property, "w:numPr");
|
open!(open_numbering_property, "w:numPr");
|
||||||
only_usize_val_el!(indent_level, "w:ilvl");
|
closed_with_usize!(indent_level, "w:ilvl");
|
||||||
only_usize_val_el!(num_id, "w:numId");
|
closed_with_usize!(num_id, "w:numId");
|
||||||
only_usize_val_el!(start, "w:start");
|
closed_with_usize!(start, "w:start");
|
||||||
only_str_val_el!(number_format, "w:numFmt");
|
closed_with_str!(number_format, "w:numFmt");
|
||||||
only_str_val_el!(level_text, "w:lvlText");
|
closed_with_str!(level_text, "w:lvlText");
|
||||||
only_str_val_el!(level_justification, "w:lvlJc");
|
closed_with_str!(level_justification, "w:lvlJc");
|
||||||
only_str_val_el!(abstract_num_id, "w:abstractNumId");
|
closed_with_str!(abstract_num_id, "w:abstractNumId");
|
||||||
closed_el!(vanish, "w:vanish");
|
closed!(vanish, "w:vanish");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
macro_rules! opened_el {
|
macro_rules! open {
|
||||||
($name: ident, $el_name: expr) => {
|
($name: ident, $el_name: expr) => {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub(crate) fn $name(mut self) -> Self {
|
pub(crate) fn $name(mut self) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
.write(XmlEvent::start_element($el_name))
|
.write(XmlEvent::start_element($el_name))
|
||||||
|
@ -49,7 +50,7 @@ macro_rules! opened_el {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! opened_el_with_attrs {
|
macro_rules! open_with_attrs {
|
||||||
($name: ident, $el_name: expr) => {
|
($name: ident, $el_name: expr) => {
|
||||||
pub(crate) fn $name(mut self, attrs: &[(String, String)]) -> Self {
|
pub(crate) fn $name(mut self, attrs: &[(String, String)]) -> Self {
|
||||||
let mut e = XmlEvent::start_element($el_name);
|
let mut e = XmlEvent::start_element($el_name);
|
||||||
|
@ -57,7 +58,7 @@ macro_rules! opened_el_with_attrs {
|
||||||
let mut key: &str = "";
|
let mut key: &str = "";
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
let mut val: &str = "";
|
let mut val: &str = "";
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
key = &attr.0;
|
key = &attr.0;
|
||||||
val = &attr.1;
|
val = &attr.1;
|
||||||
e = e.attr(key, val);
|
e = e.attr(key, val);
|
||||||
|
@ -70,8 +71,9 @@ macro_rules! opened_el_with_attrs {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! closed_el_with_child {
|
macro_rules! closed_with_child {
|
||||||
($name: ident, $el_name: expr) => {
|
($name: ident, $el_name: expr) => {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub(crate) fn $name(mut self, child: &str) -> Self {
|
pub(crate) fn $name(mut self, child: &str) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
.write(XmlEvent::start_element($el_name))
|
.write(XmlEvent::start_element($el_name))
|
||||||
|
@ -117,7 +119,7 @@ macro_rules! closed_el_with_child {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! closed_el {
|
macro_rules! closed {
|
||||||
($name: ident, $el_name: expr) => {
|
($name: ident, $el_name: expr) => {
|
||||||
pub(crate) fn $name(mut self) -> Self {
|
pub(crate) fn $name(mut self) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
|
@ -135,6 +137,7 @@ macro_rules! closed_el {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($name: ident, $el_name: expr, $attr0: expr, $attr1: expr) => {
|
($name: ident, $el_name: expr, $attr0: expr, $attr1: expr) => {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub(crate) fn $name(mut self, arg0: &str, arg1: &str) -> Self {
|
pub(crate) fn $name(mut self, arg0: &str, arg1: &str) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
.write(XmlEvent::start_element($el_name).attr($attr0, arg0).attr($attr1, arg1))
|
.write(XmlEvent::start_element($el_name).attr($attr0, arg0).attr($attr1, arg1))
|
||||||
|
@ -175,6 +178,7 @@ macro_rules! closed_el {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($name: ident, $el_name: expr, $attr0: expr, $attr1: expr, $attr2: expr, $attr3: expr, $attr4: expr, $attr5: expr, $attr6: expr) => {
|
($name: ident, $el_name: expr, $attr0: expr, $attr1: expr, $attr2: expr, $attr3: expr, $attr4: expr, $attr5: expr, $attr6: expr) => {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub(crate) fn $name(mut self, arg0: &str, arg1: &str, arg2: &str, arg3: &str, arg4: &str, arg5: &str, arg6: &str) -> Self {
|
pub(crate) fn $name(mut self, arg0: &str, arg1: &str, arg2: &str, arg3: &str, arg4: &str, arg5: &str, arg6: &str) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
.write(XmlEvent::start_element($el_name).attr($attr0, arg0).attr($attr1, arg1).attr($attr2, arg2).attr($attr3, arg3).attr($attr4, arg4).attr($attr5, arg5).attr($attr6, arg6))
|
.write(XmlEvent::start_element($el_name).attr($attr0, arg0).attr($attr1, arg1).attr($attr2, arg2).attr($attr3, arg3).attr($attr4, arg4).attr($attr5, arg5).attr($attr6, arg6))
|
||||||
|
@ -183,6 +187,7 @@ macro_rules! closed_el {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($name: ident, $el_name: expr, $attr0: expr, $attr1: expr, $attr2: expr, $attr3: expr, $attr4: expr, $attr5: expr, $attr6: expr, $attr7: expr) => {
|
($name: ident, $el_name: expr, $attr0: expr, $attr1: expr, $attr2: expr, $attr3: expr, $attr4: expr, $attr5: expr, $attr6: expr, $attr7: expr) => {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub(crate) fn $name(mut self, arg0: &str, arg1: &str, arg2: &str, arg3: &str, arg4: &str, arg5: &str, arg6: &str, arg7: &str) -> Self {
|
pub(crate) fn $name(mut self, arg0: &str, arg1: &str, arg2: &str, arg3: &str, arg4: &str, arg5: &str, arg6: &str, arg7: &str) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
.write(XmlEvent::start_element($el_name).attr($attr0, arg0).attr($attr1, arg1).attr($attr2, arg2).attr($attr3, arg3).attr($attr4, arg4).attr($attr5, arg5).attr($attr6, arg6).attr($attr7, arg7))
|
.write(XmlEvent::start_element($el_name).attr($attr0, arg0).attr($attr1, arg1).attr($attr2, arg2).attr($attr3, arg3).attr($attr4, arg4).attr($attr5, arg5).attr($attr6, arg6).attr($attr7, arg7))
|
||||||
|
@ -191,6 +196,7 @@ macro_rules! closed_el {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($name: ident, $el_name: expr, $attr0: expr, $attr1: expr, $attr2: expr, $attr3: expr, $attr4: expr, $attr5: expr, $attr6: expr, $attr7: expr, $attr8: expr) => {
|
($name: ident, $el_name: expr, $attr0: expr, $attr1: expr, $attr2: expr, $attr3: expr, $attr4: expr, $attr5: expr, $attr6: expr, $attr7: expr, $attr8: expr) => {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub(crate) fn $name(mut self, arg0: &str, arg1: &str, arg2: &str, arg3: &str, arg4: &str, arg5: &str, arg6: &str, arg7: &str, arg8: &str) -> Self {
|
pub(crate) fn $name(mut self, arg0: &str, arg1: &str, arg2: &str, arg3: &str, arg4: &str, arg5: &str, arg6: &str, arg7: &str, arg8: &str) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
.write(XmlEvent::start_element($el_name).attr($attr0, arg0).attr($attr1, arg1).attr($attr2, arg2).attr($attr3, arg3).attr($attr4, arg4).attr($attr5, arg5).attr($attr6, arg6).attr($attr7, arg7).attr($attr8, arg8))
|
.write(XmlEvent::start_element($el_name).attr($attr0, arg0).attr($attr1, arg1).attr($attr2, arg2).attr($attr3, arg3).attr($attr4, arg4).attr($attr5, arg5).attr($attr6, arg6).attr($attr7, arg7).attr($attr8, arg8))
|
||||||
|
@ -200,8 +206,9 @@ macro_rules! closed_el {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! only_str_val_el {
|
macro_rules! closed_with_str {
|
||||||
($name: ident, $el_name: expr) => {
|
($name: ident, $el_name: expr) => {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub(crate) fn $name(mut self, val: &str) -> Self {
|
pub(crate) fn $name(mut self, val: &str) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
.write(XmlEvent::start_element($el_name).attr("w:val", val))
|
.write(XmlEvent::start_element($el_name).attr("w:val", val))
|
||||||
|
@ -211,7 +218,7 @@ macro_rules! only_str_val_el {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! only_usize_val_el {
|
macro_rules! closed_with_usize {
|
||||||
($name: ident, $el_name: expr) => {
|
($name: ident, $el_name: expr) => {
|
||||||
pub(crate) fn $name(mut self, val: usize) -> Self {
|
pub(crate) fn $name(mut self, val: usize) -> Self {
|
||||||
self.writer
|
self.writer
|
||||||
|
|
|
@ -4,16 +4,16 @@ use super::XmlEvent;
|
||||||
impl XMLBuilder {
|
impl XMLBuilder {
|
||||||
// Build Properties element
|
// Build Properties element
|
||||||
// i.e. <Properties xmlns:vt="http://schemas.openxmlformats.org/package/2006/relationships">
|
// i.e. <Properties xmlns:vt="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||||
opened_el!(open_properties, "Properties", "xmlns", "xmlns:vt");
|
open!(open_properties, "Properties", "xmlns", "xmlns:vt");
|
||||||
|
|
||||||
closed_el_with_child!(template, "Template");
|
closed_with_child!(template, "Template");
|
||||||
closed_el_with_child!(total_time, "TotalTime");
|
closed_with_child!(total_time, "TotalTime");
|
||||||
closed_el_with_child!(application, "Application");
|
closed_with_child!(application, "Application");
|
||||||
closed_el_with_child!(pages, "Pages");
|
closed_with_child!(pages, "Pages");
|
||||||
closed_el_with_child!(words, "Words");
|
closed_with_child!(words, "Words");
|
||||||
closed_el_with_child!(characters, "Characters");
|
closed_with_child!(characters, "Characters");
|
||||||
closed_el_with_child!(characters_with_spaces, "CharactersWithSpaces");
|
closed_with_child!(characters_with_spaces, "CharactersWithSpaces");
|
||||||
closed_el_with_child!(paragraphs, "Paragraphs");
|
closed_with_child!(paragraphs, "Paragraphs");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -4,10 +4,10 @@ use super::XmlEvent;
|
||||||
impl XMLBuilder {
|
impl XMLBuilder {
|
||||||
// Build RelationShips element
|
// Build RelationShips element
|
||||||
// i.e. <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
// i.e. <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||||
opened_el!(open_relationships, "Relationships", "xmlns");
|
open!(open_relationships, "Relationships", "xmlns");
|
||||||
|
|
||||||
// Build Relationship
|
// Build Relationship
|
||||||
closed_el!(relationship, "Relationship", "Id", "Type", "Target");
|
closed!(relationship, "Relationship", "Id", "Type", "Target");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -5,11 +5,7 @@ pub fn create_special_indent(
|
||||||
special_indent_size: Option<usize>,
|
special_indent_size: Option<usize>,
|
||||||
) -> Option<docx_core::SpecialIndentType> {
|
) -> Option<docx_core::SpecialIndentType> {
|
||||||
if let Some(kind) = special_indent_kind {
|
if let Some(kind) = special_indent_kind {
|
||||||
let size = if special_indent_size.is_some() {
|
let size = special_indent_size.unwrap_or_else(|| 0);
|
||||||
special_indent_size.unwrap()
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
match kind {
|
match kind {
|
||||||
docx_core::SpecialIndentKind::FirstLine => {
|
docx_core::SpecialIndentKind::FirstLine => {
|
||||||
Some(docx_core::SpecialIndentType::FirstLine(size))
|
Some(docx_core::SpecialIndentType::FirstLine(size))
|
||||||
|
|
|
@ -20,12 +20,12 @@ impl Comment {
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl Comment {
|
impl Comment {
|
||||||
pub fn author(mut self, author: String) -> Comment {
|
pub fn author(mut self, author: String) -> Comment {
|
||||||
self.0.author = author.into();
|
self.0.author = author;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn date(mut self, date: String) -> Comment {
|
pub fn date(mut self, date: String) -> Comment {
|
||||||
self.0.date = date.into();
|
self.0.date = date;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,9 @@ impl Paragraph {
|
||||||
pub fn add_comment_start(mut self, comment: Comment) -> Paragraph {
|
pub fn add_comment_start(mut self, comment: Comment) -> Paragraph {
|
||||||
self.0
|
self.0
|
||||||
.children
|
.children
|
||||||
.push(docx_core::ParagraphChild::CommentStart(
|
.push(docx_core::ParagraphChild::CommentStart(Box::new(
|
||||||
docx_core::CommentRangeStart::new(comment.take()),
|
docx_core::CommentRangeStart::new(comment.take()),
|
||||||
));
|
)));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
makefile
3
makefile
|
@ -1,6 +1,9 @@
|
||||||
test:
|
test:
|
||||||
cargo test
|
cargo test
|
||||||
|
|
||||||
|
lint:
|
||||||
|
cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
vrt:
|
vrt:
|
||||||
node vrt/index.js && reg-cli vrt/screenshot/actual vrt/screenshot/expected vrt/screenshot/diff -R vrt/report.html -I
|
node vrt/index.js && reg-cli vrt/screenshot/actual vrt/screenshot/expected vrt/screenshot/diff -R vrt/report.html -I
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue