mirror of
https://github.com/fumiama/go-docx.git
synced 2026-06-12 11:40:28 +08:00
add xmlns wp
This commit is contained in:
5
empty.go
5
empty.go
@@ -8,8 +8,9 @@ func newEmptyFile() *Docx {
|
|||||||
XMLName: xml.Name{
|
XMLName: xml.Name{
|
||||||
Space: "w",
|
Space: "w",
|
||||||
},
|
},
|
||||||
XMLW: XMLNS_W,
|
XMLW: XMLNS_W,
|
||||||
XMLR: XMLNS_R,
|
XMLR: XMLNS_R,
|
||||||
|
XMLWP: XMLNS_WP,
|
||||||
Body: &Body{
|
Body: &Body{
|
||||||
XMLName: xml.Name{
|
XMLName: xml.Name{
|
||||||
Space: "w",
|
Space: "w",
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package docxlib
|
|||||||
import "encoding/xml"
|
import "encoding/xml"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
XMLNS_W = `http://schemas.openxmlformats.org/wordprocessingml/2006/main`
|
XMLNS_W = `http://schemas.openxmlformats.org/wordprocessingml/2006/main`
|
||||||
XMLNS_R = `http://schemas.openxmlformats.org/officeDocument/2006/relationships`
|
XMLNS_R = `http://schemas.openxmlformats.org/officeDocument/2006/relationships`
|
||||||
|
XMLNS_WP = `http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing`
|
||||||
)
|
)
|
||||||
|
|
||||||
type Body struct {
|
type Body struct {
|
||||||
@@ -16,5 +17,6 @@ type Document struct {
|
|||||||
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/wordprocessingml/2006/main document"`
|
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/wordprocessingml/2006/main document"`
|
||||||
XMLW string `xml:"xmlns:w,attr"`
|
XMLW string `xml:"xmlns:w,attr"`
|
||||||
XMLR string `xml:"xmlns:r,attr"`
|
XMLR string `xml:"xmlns:r,attr"`
|
||||||
|
XMLWP string `xml:"xmlns:wp,attr"`
|
||||||
Body *Body
|
Body *Body
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ func TestPlainStructure(t *testing.T) {
|
|||||||
doc := Document{
|
doc := Document{
|
||||||
XMLW: XMLNS_W,
|
XMLW: XMLNS_W,
|
||||||
XMLR: XMLNS_R,
|
XMLR: XMLNS_R,
|
||||||
|
XMLWP: XMLNS_WP,
|
||||||
XMLName: xml.Name{Space: XMLNS_W, Local: "document"}}
|
XMLName: xml.Name{Space: XMLNS_W, Local: "document"}}
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
content string
|
content string
|
||||||
@@ -515,6 +516,7 @@ func TestDrawingStructure(t *testing.T) {
|
|||||||
doc := Document{
|
doc := Document{
|
||||||
XMLW: XMLNS_W,
|
XMLW: XMLNS_W,
|
||||||
XMLR: XMLNS_R,
|
XMLR: XMLNS_R,
|
||||||
|
XMLWP: XMLNS_WP,
|
||||||
XMLName: xml.Name{Space: XMLNS_W, Local: "document"}}
|
XMLName: xml.Name{Space: XMLNS_W, Local: "document"}}
|
||||||
err := xml.Unmarshal(StringToBytes(drawing_doc), &doc)
|
err := xml.Unmarshal(StringToBytes(drawing_doc), &doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ type Drawing struct {
|
|||||||
// WPInline wp:inline
|
// WPInline wp:inline
|
||||||
type WPInline struct {
|
type WPInline struct {
|
||||||
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing inline,omitempty"`
|
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing inline,omitempty"`
|
||||||
DistT string `xml:"wp:distT,attr"`
|
DistT string `xml:"distT,attr"`
|
||||||
DistB string `xml:"wp:distB,attr"`
|
DistB string `xml:"distB,attr"`
|
||||||
DistL string `xml:"wp:distL,attr"`
|
DistL string `xml:"distL,attr"`
|
||||||
DistR string `xml:"wp:distR,attr"`
|
DistR string `xml:"distR,attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunProperties encapsulates visual properties of a run
|
// RunProperties encapsulates visual properties of a run
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ func processDoc(file *zip.File, doc *Document) error {
|
|||||||
|
|
||||||
doc.XMLW = XMLNS_W
|
doc.XMLW = XMLNS_W
|
||||||
doc.XMLR = XMLNS_R
|
doc.XMLR = XMLNS_R
|
||||||
|
doc.XMLWP = XMLNS_WP
|
||||||
doc.XMLName.Space = XMLNS_W
|
doc.XMLName.Space = XMLNS_W
|
||||||
doc.XMLName.Local = "document"
|
doc.XMLName.Local = "document"
|
||||||
err = xml.Unmarshal(filebytes, doc)
|
err = xml.Unmarshal(filebytes, doc)
|
||||||
|
|||||||
Reference in New Issue
Block a user