Skip to content

Commit

Permalink
optimize(drawing): use implicit a:graphicFrameLocks
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Sep 17, 2024
1 parent 3e5e3f4 commit f03badc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apidrawing.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (p *Paragraph) AddInlineDrawing(pic []byte) (*Run, error) {
},
CNvGraphicFramePr: &WPCNvGraphicFramePr{
Locks: AGraphicFrameLocks{
XMLA: XMLNS_DRAWINGML_MAIN,
NoChangeAspect: 1,
},
},
Expand Down Expand Up @@ -174,6 +175,7 @@ func (p *Paragraph) AddAnchorDrawing(pic []byte) (*Run, error) {
},
CNvGraphicFramePr: &WPCNvGraphicFramePr{
Locks: AGraphicFrameLocks{
XMLA: XMLNS_DRAWINGML_MAIN,
NoChangeAspect: 1,
},
},
Expand Down
8 changes: 6 additions & 2 deletions apishape.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
4 changes: 3 additions & 1 deletion structdrawing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"`
}

Expand Down

0 comments on commit f03badc

Please sign in to comment.