From 592c7b5d1371fa7cbf96d67bb4c94767f09d254a 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: Sun, 26 Feb 2023 13:48:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96table=20attr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- structtable.go | 22 ++++++++++++++-------- unpack.go | 3 +++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/structtable.go b/structtable.go index 76199f0..57c4fee 100644 --- a/structtable.go +++ b/structtable.go @@ -164,12 +164,14 @@ func (t *WTableProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) // and vertical anchors, distance from text, and coordinates. type WTablePositioningProperties struct { XMLName xml.Name `xml:"w:tblpPr,omitempty"` - LeftFromText int `xml:"w:leftFromText,attr"` - RightFromText int `xml:"w:rightFromText,attr"` - VertAnchor string `xml:"w:vertAnchor,attr"` - HorzAnchor string `xml:"w:horzAnchor,attr"` - TblpX int `xml:"w:tblpX,attr"` - TblpY int `xml:"w:tblpY,attr"` + LeftFromText int `xml:"w:leftFromText,attr,omitempty"` + RightFromText int `xml:"w:rightFromText,attr,omitempty"` + VertAnchor string `xml:"w:vertAnchor,attr,omitempty"` + HorzAnchor string `xml:"w:horzAnchor,attr,omitempty"` + TblpXSpec string `xml:"w:tblpXSpec,attr,omitempty"` + TblpYSpec string `xml:"w:tblpYSpec,attr,omitempty"` + TblpX int `xml:"w:tblpX,attr,omitempty"` + TblpY int `xml:"w:tblpY,attr,omitempty"` } // UnmarshalXML ... @@ -190,6 +192,10 @@ func (tp *WTablePositioningProperties) UnmarshalXML(d *xml.Decoder, start xml.St tp.VertAnchor = attr.Value case "horzAnchor": tp.HorzAnchor = attr.Value + case "tblpXSpec": + tp.TblpXSpec = attr.Value + case "tblpYSpec": + tp.TblpYSpec = attr.Value case "tblpX": tp.TblpX, err = strconv.Atoi(attr.Value) if err != nil { @@ -375,8 +381,8 @@ func (g *WGridCol) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err err // WTableRow represents a row within a table. type WTableRow struct { XMLName xml.Name `xml:"w:tr,omitempty"` - RsidR string `xml:"w:rsidR,attr"` - RsidTr string `xml:"w:rsidTr,attr"` + RsidR string `xml:"w:rsidR,attr,omitempty"` + RsidTr string `xml:"w:rsidTr,attr,omitempty"` TableRowProperties *WTableRowProperties TableCells []*WTableCell diff --git a/unpack.go b/unpack.go index d30600d..e705f6f 100644 --- a/unpack.go +++ b/unpack.go @@ -33,6 +33,9 @@ import ( // // 1. Document // 2. Relationships +// 3. Media +// +// Then it stores all other files into tmpfslist for packing. func unpack(zipReader *zip.Reader) (docx *Docx, err error) { docx = new(Docx) docx.mediaNameIdx = make(map[string]int, 64)