From f03badc77c248494c4f2b6c5ad2588bf967a0487 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: Tue, 17 Sep 2024 21:41:46 +0900 Subject: [PATCH] optimize(drawing): use implicit a:graphicFrameLocks --- apidrawing.go | 2 ++ apishape.go | 8 ++++++-- structdrawing.go | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apidrawing.go b/apidrawing.go index 8567851..e2e7c61 100644 --- a/apidrawing.go +++ b/apidrawing.go @@ -63,6 +63,7 @@ func (p *Paragraph) AddInlineDrawing(pic []byte) (*Run, error) { }, CNvGraphicFramePr: &WPCNvGraphicFramePr{ Locks: AGraphicFrameLocks{ + XMLA: XMLNS_DRAWINGML_MAIN, NoChangeAspect: 1, }, }, @@ -174,6 +175,7 @@ func (p *Paragraph) AddAnchorDrawing(pic []byte) (*Run, error) { }, CNvGraphicFramePr: &WPCNvGraphicFramePr{ Locks: AGraphicFrameLocks{ + XMLA: XMLNS_DRAWINGML_MAIN, NoChangeAspect: 1, }, }, diff --git a/apishape.go b/apishape.go index 5ebcd49..4ca918a 100644 --- a/apishape.go +++ b/apishape.go @@ -40,7 +40,9 @@ func (p *Paragraph) AddInlineShape(w, h int64, name, bwMode, prst string, ln *AL ID: idn, Name: name + " " + id, }, - CNvGraphicFramePr: &WPCNvGraphicFramePr{}, + CNvGraphicFramePr: &WPCNvGraphicFramePr{ + Locks: AGraphicFrameLocks{XMLA: XMLNS_DRAWINGML_MAIN}, + }, Graphic: &AGraphic{ XMLA: XMLNS_DRAWINGML_MAIN, GraphicData: &AGraphicData{ @@ -107,7 +109,9 @@ func (p *Paragraph) AddAnchorShape(w, h int64, name, bwMode, prst string, ln *AL ID: idn, Name: name + " " + id, }, - CNvGraphicFramePr: &WPCNvGraphicFramePr{}, + CNvGraphicFramePr: &WPCNvGraphicFramePr{ + Locks: AGraphicFrameLocks{XMLA: XMLNS_DRAWINGML_MAIN}, + }, Graphic: &AGraphic{ XMLA: XMLNS_DRAWINGML_MAIN, GraphicData: &AGraphicData{ diff --git a/structdrawing.go b/structdrawing.go index 733bc8e..78e348e 100644 --- a/structdrawing.go +++ b/structdrawing.go @@ -450,6 +450,7 @@ func (w *WPCNvGraphicFramePr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) e if tt, ok := t.(xml.StartElement); ok { switch tt.Name.Local { case "graphicFrameLocks": + w.Locks.XMLA = getAtt(tt.Attr, "a") v := getAtt(tt.Attr, "noChangeAspect") if v == "" { continue @@ -472,7 +473,8 @@ func (w *WPCNvGraphicFramePr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) e // AGraphicFrameLocks represents the locks applied to a graphic frame. type AGraphicFrameLocks struct { - XMLName xml.Name `xml:"http://schemas.openxmlformats.org/drawingml/2006/main graphicFrameLocks,omitempty"` + XMLName xml.Name `xml:"a:graphicFrameLocks,omitempty"` + XMLA string `xml:"xmlns:a,attr,omitempty"` NoChangeAspect int `xml:"noChangeAspect,attr,omitempty"` }