mirror of
https://github.com/fumiama/go-docx.git
synced 2026-06-22 19:40:42 +08:00
add: xmlns:wp14 in Document
This commit is contained in:
@@ -5,6 +5,10 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HYPERLINK_STYLE = "a1"
|
||||||
|
)
|
||||||
|
|
||||||
// when adding an hyperlink we need to store a reference in the relationship field
|
// when adding an hyperlink we need to store a reference in the relationship field
|
||||||
func (f *Docx) addLinkRelation(link string) string {
|
func (f *Docx) addLinkRelation(link string) string {
|
||||||
rel := &Relationship{
|
rel := &Relationship{
|
||||||
|
|||||||
7
empty.go
7
empty.go
@@ -11,9 +11,10 @@ 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,
|
XMLWP: XMLNS_WP,
|
||||||
|
XMLWP14: XMLNS_WP14,
|
||||||
Body: &Body{
|
Body: &Body{
|
||||||
XMLName: xml.Name{
|
XMLName: xml.Name{
|
||||||
Space: "w",
|
Space: "w",
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ 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`
|
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 {
|
func getAtt(atts []xml.Attr, name string) string {
|
||||||
@@ -27,5 +28,6 @@ type Document struct {
|
|||||||
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"`
|
XMLWP string `xml:"xmlns:wp,attr"`
|
||||||
|
XMLWP14 string `xml:"xmlns:wp14,attr"`
|
||||||
Body *Body
|
Body *Body
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -519,6 +519,7 @@ func TestUnmarshalDrawingStructure(t *testing.T) {
|
|||||||
XMLW: XMLNS_W,
|
XMLW: XMLNS_W,
|
||||||
XMLR: XMLNS_R,
|
XMLR: XMLNS_R,
|
||||||
XMLWP: XMLNS_WP,
|
XMLWP: XMLNS_WP,
|
||||||
|
XMLWP14: XMLNS_WP14,
|
||||||
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 {
|
||||||
|
|||||||
@@ -5,10 +5,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
HYPERLINK_STYLE = "a1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Run is part of a paragraph that has its own style. It could be
|
// Run is part of a paragraph that has its own style. It could be
|
||||||
// a piece of text in bold, or a link
|
// a piece of text in bold, or a link
|
||||||
type Run struct {
|
type Run struct {
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ func (f *Docx) parseDocument(file *zip.File) error {
|
|||||||
f.Document.XMLW = XMLNS_W
|
f.Document.XMLW = XMLNS_W
|
||||||
f.Document.XMLR = XMLNS_R
|
f.Document.XMLR = XMLNS_R
|
||||||
f.Document.XMLWP = XMLNS_WP
|
f.Document.XMLWP = XMLNS_WP
|
||||||
|
f.Document.XMLWP14 = XMLNS_WP14
|
||||||
f.Document.XMLName.Space = XMLNS_W
|
f.Document.XMLName.Space = XMLNS_W
|
||||||
f.Document.XMLName.Local = "document"
|
f.Document.XMLName.Local = "document"
|
||||||
err = xml.NewDecoder(zf).Decode(&f.Document)
|
err = xml.NewDecoder(zf).Decode(&f.Document)
|
||||||
|
|||||||
Reference in New Issue
Block a user