git.iko.soy/typeable/pandoc
on master help sign in
Docx writer: added framework for custom properties.

So far, we don't actually write any custom properties, but we have the infrastructure to add this. See #3034.

commit30033f417f3009eb8c4b5fa8302cea7fecad48ee authorJohn MacFarlane <jgm@berkeley.edu> dateTue 9 Oct 2018, 10:38 (8 years ago) parent4d9ccb1
31 files changed+26−3
data/docx/[Content_Types].xml+1−1 data/docx/_rels/.rels+2−1 data/docx/docProps/custom.xml+2 src/Text/Pandoc/Class.hs+1 src/Text/Pandoc/Writers/Docx.hs+20−1 test/docx/golden/block_quotes.docx test/docx/golden/codeblock.docx test/docx/golden/comments.docx test/docx/golden/custom_style_no_reference.docx test/docx/golden/custom_style_reference.docx test/docx/golden/definition_list.docx test/docx/golden/headers.docx test/docx/golden/image.docx test/docx/golden/inline_code.docx test/docx/golden/inline_formatting.docx test/docx/golden/inline_images.docx test/docx/golden/link_in_notes.docx test/docx/golden/links.docx test/docx/golden/lists.docx test/docx/golden/lists_continuing.docx test/docx/golden/lists_restarting.docx test/docx/golden/nested_anchors_in_header.docx test/docx/golden/notes.docx test/docx/golden/table_one_row.docx test/docx/golden/table_with_list_cell.docx test/docx/golden/tables.docx test/docx/golden/track_changes_deletion.docx test/docx/golden/track_changes_insertion.docx test/docx/golden/track_changes_move.docx test/docx/golden/unicode.docx test/docx/golden/verbatim_subsuper.docx
data/docx/[Content_Types].xml+1−1
@@ -1,2 +1,2 @@
11<?xml version="1.0" encoding="UTF-8"?>
2−<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml" /><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml" /><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" /><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" /><Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" /><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" /><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" /><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" /><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" /><Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" /><Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" /></Types>
2+<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml" /><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml" /><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" /><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" /><Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" /><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" /><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" /><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /><Override PartName="/docProps/custom.xml" ContentType="application/vnd.openxmlformats-officedocument.custom-properties+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" /><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" /><Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" /><Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" /></Types>
data/docx/_rels/.rels+2−1
@@ -1,2 +1,3 @@
11<?xml version="1.0" encoding="UTF-8"?>
2−<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" /><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" /></Relationships>
2+<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" /><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" /><Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" Target="docProps/custom.xml"/>
3+</Relationships>
data/docx/docProps/custom.xmlnew file+2
@@ -0,0 +1,2 @@
1+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"></Properties>
src/Text/Pandoc/Class.hs+1
@@ -629,6 +629,7 @@ getDefaultReferenceDocx = do
629629 "_rels/.rels",
630630 "docProps/app.xml",
631631 "docProps/core.xml",
632+ "docProps/custom.xml",
632633 "word/document.xml",
633634 "word/fontTable.xml",
634635 "word/footnotes.xml",
src/Text/Pandoc/Writers/Docx.hs+20−1
@@ -349,6 +349,8 @@ writeDocx opts doc@(Pandoc meta _) = do
349349 "application/vnd.openxmlformats-officedocument.extended-properties+xml")
350350 ,("/docProps/core.xml",
351351 "application/vnd.openxmlformats-package.core-properties+xml")
352+ ,("/docProps/custom.xml",
353+ "application/vnd.openxmlformats-officedocument.custom-properties+xml")
352354 ,("/word/styles.xml",
353355 "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml")
354356 ,("/word/document.xml",
@@ -507,6 +509,19 @@ writeDocx opts doc@(Pandoc meta _) = do
507509 ]) (formatTime defaultTimeLocale "%FT%XZ" utctime)
508510 let docPropsEntry = toEntry docPropsPath epochtime $ renderXml docProps
509511
512+ let customProperties :: [(String, String)]
513+ customProperties = [] -- FIXME
514+ let mkCustomProp (k, v) pid = mknode "property"
515+ [("fmtid","{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
516+ ,("pid", show pid)
517+ ,("name", k)] $ mknode "vt:lpwstr" [] v
518+ let customPropsPath = "docProps/custom.xml"
519+ let customProps = mknode "Properties"
520+ [("xmlns","http://schemas.openxmlformats.org/officeDocument/2006/custom-properties")
521+ ,("xmlns:vt","http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes")
522+ ] $ zipWith mkCustomProp customProperties [(2 :: Int)..]
523+ let customPropsEntry = toEntry customPropsPath epochtime $ renderXml customProps
524+
510525 let relsPath = "_rels/.rels"
511526 let rels = mknode "Relationships" [("xmlns", "http://schemas.openxmlformats.org/package/2006/relationships")]
512527 $ map (\attrs -> mknode "Relationship" attrs ())
@@ -519,6 +534,9 @@ writeDocx opts doc@(Pandoc meta _) = do
519534 , [("Id","rId3")
520535 ,("Type","http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties")
521536 ,("Target","docProps/core.xml")]
537+ , [("Id","rId5")
538+ ,("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties")
539+ ,("Target","docProps/custom.xml")]
522540 ]
523541 let relsEntry = toEntry relsPath epochtime $ renderXml rels
524542
@@ -558,7 +576,8 @@ writeDocx opts doc@(Pandoc meta _) = do
558576 contentTypesEntry : relsEntry : contentEntry : relEntry :
559577 footnoteRelEntry : numEntry : styleEntry : footnotesEntry :
560578 commentsEntry :
561− docPropsEntry : docPropsAppEntry : themeEntry :
579+ docPropsEntry : docPropsAppEntry : customPropsEntry :
580+ themeEntry :
562581 fontTableEntry : settingsEntry : webSettingsEntry :
563582 imageEntries ++ headerFooterEntries ++
564583 miscRelEntries ++ otherMediaEntries
test/docx/golden/block_quotes.docx

Binary file not shown.

test/docx/golden/codeblock.docx

Binary file not shown.

test/docx/golden/comments.docx

Binary file not shown.

test/docx/golden/custom_style_no_reference.docx

Binary file not shown.

test/docx/golden/custom_style_reference.docx

Binary file not shown.

test/docx/golden/definition_list.docx

Binary file not shown.

test/docx/golden/headers.docx

Binary file not shown.

test/docx/golden/image.docx

Binary file not shown.

test/docx/golden/inline_code.docx

Binary file not shown.

test/docx/golden/inline_formatting.docx

Binary file not shown.

test/docx/golden/inline_images.docx

Binary file not shown.

test/docx/golden/link_in_notes.docx

Binary file not shown.

test/docx/golden/links.docx

Binary file not shown.

test/docx/golden/lists.docx

Binary file not shown.

test/docx/golden/lists_continuing.docx

Binary file not shown.

test/docx/golden/lists_restarting.docx

Binary file not shown.

test/docx/golden/nested_anchors_in_header.docx

Binary file not shown.

test/docx/golden/notes.docx

Binary file not shown.

test/docx/golden/table_one_row.docx

Binary file not shown.

test/docx/golden/table_with_list_cell.docx

Binary file not shown.

test/docx/golden/tables.docx

Binary file not shown.

test/docx/golden/track_changes_deletion.docx

Binary file not shown.

test/docx/golden/track_changes_insertion.docx

Binary file not shown.

test/docx/golden/track_changes_move.docx

Binary file not shown.

test/docx/golden/unicode.docx

Binary file not shown.

test/docx/golden/verbatim_subsuper.docx

Binary file not shown.