From d10c5b0cb3dc2987c1f900d744761b6f6d81806a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 15 Feb 2023 14:10:48 +0800 Subject: [PATCH] add: xmlns:wp14 in Document --- apilink.go | 4 ++++ empty.go | 7 ++++--- structdoc.go | 8 +++++--- structdoc_test.go | 1 + structrun.go | 4 ---- unpack.go | 1 + 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apilink.go b/apilink.go index cc522fa..c72506e 100644 --- a/apilink.go +++ b/apilink.go @@ -5,6 +5,10 @@ import ( "sync/atomic" ) +const ( + HYPERLINK_STYLE = "a1" +) + // when adding an hyperlink we need to store a reference in the relationship field func (f *Docx) addLinkRelation(link string) string { rel := &Relationship{ diff --git a/empty.go b/empty.go index 3865eb9..1181721 100644 --- a/empty.go +++ b/empty.go @@ -11,9 +11,10 @@ func newEmptyFile() *Docx { XMLName: xml.Name{ Space: "w", }, - XMLW: XMLNS_W, - XMLR: XMLNS_R, - XMLWP: XMLNS_WP, + XMLW: XMLNS_W, + XMLR: XMLNS_R, + XMLWP: XMLNS_WP, + XMLWP14: XMLNS_WP14, Body: &Body{ XMLName: xml.Name{ Space: "w", diff --git a/structdoc.go b/structdoc.go index e62d0db..cb7063b 100644 --- a/structdoc.go +++ b/structdoc.go @@ -3,9 +3,10 @@ package docxlib import "encoding/xml" const ( - XMLNS_W = `http://schemas.openxmlformats.org/wordprocessingml/2006/main` - XMLNS_R = `http://schemas.openxmlformats.org/officeDocument/2006/relationships` - XMLNS_WP = `http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing` + XMLNS_W = `http://schemas.openxmlformats.org/wordprocessingml/2006/main` + XMLNS_R = `http://schemas.openxmlformats.org/officeDocument/2006/relationships` + XMLNS_WP = `http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing` + XMLNS_WP14 = `http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing` ) func getAtt(atts []xml.Attr, name string) string { @@ -27,5 +28,6 @@ type Document struct { XMLW string `xml:"xmlns:w,attr"` XMLR string `xml:"xmlns:r,attr"` XMLWP string `xml:"xmlns:wp,attr"` + XMLWP14 string `xml:"xmlns:wp14,attr"` Body *Body } diff --git a/structdoc_test.go b/structdoc_test.go index 16297bf..c603256 100644 --- a/structdoc_test.go +++ b/structdoc_test.go @@ -519,6 +519,7 @@ func TestUnmarshalDrawingStructure(t *testing.T) { XMLW: XMLNS_W, XMLR: XMLNS_R, XMLWP: XMLNS_WP, + XMLWP14: XMLNS_WP14, XMLName: xml.Name{Space: XMLNS_W, Local: "document"}} err := xml.Unmarshal(StringToBytes(drawing_doc), &doc) if err != nil { diff --git a/structrun.go b/structrun.go index e25438d..02101bc 100644 --- a/structrun.go +++ b/structrun.go @@ -5,10 +5,6 @@ import ( "io" ) -const ( - HYPERLINK_STYLE = "a1" -) - // Run is part of a paragraph that has its own style. It could be // a piece of text in bold, or a link type Run struct { diff --git a/unpack.go b/unpack.go index 88967ff..8b8d019 100644 --- a/unpack.go +++ b/unpack.go @@ -42,6 +42,7 @@ func (f *Docx) parseDocument(file *zip.File) error { f.Document.XMLW = XMLNS_W f.Document.XMLR = XMLNS_R f.Document.XMLWP = XMLNS_WP + f.Document.XMLWP14 = XMLNS_WP14 f.Document.XMLName.Space = XMLNS_W f.Document.XMLName.Local = "document" err = xml.NewDecoder(zf).Decode(&f.Document)