feat: Support default numbering
parent
61cc95f6ba
commit
7dff9e771d
|
@ -11,10 +11,6 @@ impl XMLBuilder {
|
|||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||
)
|
||||
.attr("xmlns:o", "urn:schemas-microsoft-com:office:office")
|
||||
.attr(
|
||||
"xmlns:r",
|
||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||
)
|
||||
.attr("xmlns:v", "urn:schemas-microsoft-com:vml")
|
||||
.attr(
|
||||
"xmlns:w",
|
||||
|
|
|
@ -39,7 +39,7 @@ where
|
|||
zip.write_all(&xml.font_table)?;
|
||||
zip.start_file("word/comments.xml", options)?;
|
||||
zip.write_all(&xml.comments)?;
|
||||
zip.start_file("word/numberings.xml", options)?;
|
||||
zip.start_file("word/numbering.xml", options)?;
|
||||
zip.write_all(&xml.numberings)?;
|
||||
zip.finish()?;
|
||||
Ok(())
|
||||
|
|
|
@ -320,7 +320,26 @@ pub fn default_numbering() -> Result<(), DocxError> {
|
|||
let path = std::path::Path::new("./tests/output/default_numbering.docx");
|
||||
let file = std::fs::File::create(&path).unwrap();
|
||||
Docx::new()
|
||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
|
||||
.add_paragraph(
|
||||
Paragraph::new()
|
||||
.add_run(Run::new().add_text("Hello"))
|
||||
.numbering(NumberingId::new("0"), IndentLevel::new(0)),
|
||||
)
|
||||
.add_paragraph(
|
||||
Paragraph::new()
|
||||
.add_run(Run::new().add_text("World!"))
|
||||
.numbering(NumberingId::new("0"), IndentLevel::new(1)),
|
||||
)
|
||||
.add_paragraph(
|
||||
Paragraph::new()
|
||||
.add_run(Run::new().add_text("Foooo!"))
|
||||
.numbering(NumberingId::new("0"), IndentLevel::new(2)),
|
||||
)
|
||||
.add_paragraph(
|
||||
Paragraph::new()
|
||||
.add_run(Run::new().add_text("Bar!"))
|
||||
.numbering(NumberingId::new("0"), IndentLevel::new(3)),
|
||||
)
|
||||
.build()
|
||||
.pack(file)?;
|
||||
Ok(())
|
||||
|
|
|
@ -9,4 +9,5 @@
|
|||
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" />
|
||||
<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" />
|
||||
<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />
|
||||
<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" />
|
||||
</Types>
|
|
@ -1,6 +1,8 @@
|
|||
<?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="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml" />
|
||||
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" Target="comments.xml" />
|
||||
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml" />
|
||||
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml" />
|
||||
</Relationships>
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<w:comments 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" mc:Ignorable="w14 wp14" />
|
|
@ -15,26 +15,14 @@
|
|||
<w:pPr>
|
||||
<w:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:numPr>
|
||||
<w:numId w:val="0" />
|
||||
<w:ilvl w:val="1" />
|
||||
</w:numPr>
|
||||
</w:pPr>
|
||||
<w:commentRangeStart w:id="1" />
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:highlight w:val="cyan" />
|
||||
</w:rPr>
|
||||
<w:t xml:space="preserve">Hello</w:t>
|
||||
</w:r>
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:highlight w:val="yellow" />
|
||||
</w:rPr>
|
||||
<w:t xml:space="preserve"> World!</w:t>
|
||||
</w:r>
|
||||
<w:r>
|
||||
<w:rPr />
|
||||
</w:r>
|
||||
<w:commentRangeEnd w:id="1" />
|
||||
<w:r>
|
||||
<w:commentReference w:id="1" />
|
||||
<w:t xml:space="preserve">Hello</w:t>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</w:body>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<w:fonts xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><w:font w:name="Times New Roman">
|
||||
<w:charset w:val="00" />
|
||||
<w:family w:val="roman" />
|
||||
<w:pitch w:val="variable" />
|
||||
</w:font><w:font w:name="Symbol">
|
||||
<w:charset w:val="02" />
|
||||
<w:family w:val="roman" />
|
||||
<w:pitch w:val="variable" />
|
||||
</w:font><w:font w:name="Arial">
|
||||
<w:charset w:val="00" />
|
||||
<w:family w:val="swiss" />
|
||||
<w:pitch w:val="variable" />
|
||||
</w:font></w:fonts>
|
|
@ -0,0 +1,111 @@
|
|||
<?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:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
||||
xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
||||
<w:abstractNum w:abstractNumId="0">
|
||||
<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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="420" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="840" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="1260" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="1680" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="2100" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="2520" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="2940" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="3360" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</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:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:ind w:left="3780" w:hanging="420" />
|
||||
</w:pPr>
|
||||
</w:lvl>
|
||||
</w:abstractNum>
|
||||
<w:num w:numId="0">
|
||||
<w:abstractNumId w:val="0" />
|
||||
</w:num>
|
||||
</w:numbering>
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<w:settings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:defaultTabStop w:val="709" /><w:zoom w:percent="100" /></w:settings>
|
|
@ -1,22 +1 @@
|
|||
<w:styles xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
||||
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
||||
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
|
||||
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" mc:Ignorable="w14 w15">
|
||||
<w:docDefaults>
|
||||
<w:rPrDefault>
|
||||
<w:rPr />
|
||||
</w:rPrDefault>
|
||||
</w:docDefaults>
|
||||
<w:style w:type="paragraph" w:styleId="Normal">
|
||||
<w:name w:val="Normal" />
|
||||
<w:rPr />
|
||||
<w:pPr>
|
||||
<w:pStyle w:val="Normal" />
|
||||
<w:rPr />
|
||||
</w:pPr>
|
||||
<w:basedOn w:val="Normal" />
|
||||
<w:next w:val="Normal" />
|
||||
<w:qFormat />
|
||||
</w:style>
|
||||
</w:styles>
|
||||
<w:styles xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" mc:Ignorable="w14 w15"><w:docDefaults><w:rPrDefault><w:rPr /></w:rPrDefault></w:docDefaults><w:style w:type="paragraph" w:styleId="Normal"><w:name w:val="Normal" /><w:rPr /><w:pPr><w:pStyle w:val="Normal" /><w:rPr /></w:pPr><w:basedOn w:val="Normal" /><w:next w:val="Normal" /><w:qFormat /></w:style></w:styles>
|
Loading…
Reference in New Issue