mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00
document/spreadsheet: updates for new schema
This commit is contained in:
parent
9b53a8ea41
commit
50c3c2c990
Binary file not shown.
@ -11,17 +11,17 @@ import (
|
||||
"baliance.com/gooxml"
|
||||
"baliance.com/gooxml/measurement"
|
||||
pic "baliance.com/gooxml/schema/schemas.openxmlformats.org/drawingml/2006/picture"
|
||||
wd "baliance.com/gooxml/schema/schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
|
||||
wml "baliance.com/gooxml/schema/schemas.openxmlformats.org/wordprocessingml"
|
||||
)
|
||||
|
||||
// AnchoredDrawing is an absolutely positioned image within a document page.
|
||||
type AnchoredDrawing struct {
|
||||
d *Document
|
||||
x *wd.Anchor
|
||||
x *wml.WdAnchor
|
||||
}
|
||||
|
||||
// X returns the inner wrapped XML type.
|
||||
func (a AnchoredDrawing) X() *wd.Anchor {
|
||||
func (a AnchoredDrawing) X() *wml.WdAnchor {
|
||||
return a.x
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ func (a AnchoredDrawing) SetName(name string) {
|
||||
|
||||
// SetOrigin sets the origin of the image. It defaults to ST_RelFromHPage and
|
||||
// ST_RelFromVPage
|
||||
func (a AnchoredDrawing) SetOrigin(h wd.ST_RelFromH, v wd.ST_RelFromV) {
|
||||
func (a AnchoredDrawing) SetOrigin(h wml.WdST_RelFromH, v wml.WdST_RelFromV) {
|
||||
a.x.PositionH.RelativeFromAttr = h
|
||||
a.x.PositionV.RelativeFromAttr = v
|
||||
}
|
||||
@ -67,32 +67,32 @@ func (a AnchoredDrawing) SetOffset(x, y measurement.Distance) {
|
||||
|
||||
// SetXOffset sets the X offset for an image relative to the origin.
|
||||
func (a AnchoredDrawing) SetXOffset(x measurement.Distance) {
|
||||
a.x.PositionH.Choice = &wd.CT_PosHChoice{}
|
||||
a.x.PositionH.Choice = &wml.WdCT_PosHChoice{}
|
||||
a.x.PositionH.Choice.PosOffset = gooxml.Int32(int32(x / measurement.EMU))
|
||||
}
|
||||
|
||||
// SetYOffset sets the Y offset for an image relative to the origin.
|
||||
func (a AnchoredDrawing) SetYOffset(y measurement.Distance) {
|
||||
a.x.PositionV.Choice = &wd.CT_PosVChoice{}
|
||||
a.x.PositionV.Choice = &wml.WdCT_PosVChoice{}
|
||||
a.x.PositionV.Choice.PosOffset = gooxml.Int32(int32(y / measurement.EMU))
|
||||
}
|
||||
|
||||
// SetAlignment positions an anchored image via alignment. Offset is
|
||||
// incompatible with SetOffset, whichever is called last is applied.
|
||||
func (a AnchoredDrawing) SetAlignment(h wd.ST_AlignH, v wd.ST_AlignV) {
|
||||
func (a AnchoredDrawing) SetAlignment(h wml.WdST_AlignH, v wml.WdST_AlignV) {
|
||||
a.SetHAlignment(h)
|
||||
a.SetVAlignment(v)
|
||||
}
|
||||
|
||||
// SetHAlignment sets the horizontal alignment for an anchored image.
|
||||
func (a AnchoredDrawing) SetHAlignment(h wd.ST_AlignH) {
|
||||
a.x.PositionH.Choice = &wd.CT_PosHChoice{}
|
||||
func (a AnchoredDrawing) SetHAlignment(h wml.WdST_AlignH) {
|
||||
a.x.PositionH.Choice = &wml.WdCT_PosHChoice{}
|
||||
a.x.PositionH.Choice.Align = h
|
||||
}
|
||||
|
||||
// SetVAlignment sets the vertical alignment for an anchored image.
|
||||
func (a AnchoredDrawing) SetVAlignment(v wd.ST_AlignV) {
|
||||
a.x.PositionV.Choice = &wd.CT_PosVChoice{}
|
||||
func (a AnchoredDrawing) SetVAlignment(v wml.WdST_AlignV) {
|
||||
a.x.PositionV.Choice = &wml.WdCT_PosVChoice{}
|
||||
a.x.PositionV.Choice.Align = v
|
||||
}
|
||||
|
||||
@ -107,13 +107,13 @@ func (a AnchoredDrawing) SetSize(w, h measurement.Distance) {
|
||||
// used to place a logo at the top of a page at an absolute position that
|
||||
// doesn't interfere with text.
|
||||
func (a AnchoredDrawing) SetTextWrapNone() {
|
||||
a.x.Choice = &wd.EG_WrapTypeChoice{}
|
||||
a.x.Choice.WrapNone = wd.NewCT_WrapNone()
|
||||
a.x.Choice = &wml.WdEG_WrapTypeChoice{}
|
||||
a.x.Choice.WrapNone = wml.NewWdCT_WrapNone()
|
||||
}
|
||||
|
||||
// SetTextWrapSquare sets the text wrap to square with a given wrap type.
|
||||
func (a AnchoredDrawing) SetTextWrapSquare(t wd.ST_WrapText) {
|
||||
a.x.Choice = &wd.EG_WrapTypeChoice{}
|
||||
a.x.Choice.WrapSquare = wd.NewCT_WrapSquare()
|
||||
func (a AnchoredDrawing) SetTextWrapSquare(t wml.WdST_WrapText) {
|
||||
a.x.Choice = &wml.WdEG_WrapTypeChoice{}
|
||||
a.x.Choice.WrapSquare = wml.NewWdCT_WrapSquare()
|
||||
a.x.Choice.WrapSquare.WrapTextAttr = t
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"baliance.com/gooxml/measurement"
|
||||
dml "baliance.com/gooxml/schema/schemas.openxmlformats.org/drawingml"
|
||||
pic "baliance.com/gooxml/schema/schemas.openxmlformats.org/drawingml/2006/picture"
|
||||
wd "baliance.com/gooxml/schema/schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
|
||||
"baliance.com/gooxml/schema/schemas.openxmlformats.org/officeDocument/2006/sharedTypes"
|
||||
wml "baliance.com/gooxml/schema/schemas.openxmlformats.org/wordprocessingml"
|
||||
)
|
||||
@ -314,7 +313,7 @@ func (r Run) DrawingAnchored() []AnchoredDrawing {
|
||||
func (r Run) AddDrawingAnchored(img ImageRef) (AnchoredDrawing, error) {
|
||||
ic := r.newIC()
|
||||
ic.Drawing = wml.NewCT_Drawing()
|
||||
anchor := wd.NewAnchor()
|
||||
anchor := wml.NewWdAnchor()
|
||||
|
||||
ad := AnchoredDrawing{r.d, anchor}
|
||||
|
||||
@ -330,19 +329,19 @@ func (r Run) AddDrawingAnchored(img ImageRef) (AnchoredDrawing, error) {
|
||||
anchor.Graphic.GraphicData.UriAttr = "http://schemas.openxmlformats.org/drawingml/2006/picture"
|
||||
anchor.SimplePos.XAttr.ST_CoordinateUnqualified = gooxml.Int64(0)
|
||||
anchor.SimplePos.YAttr.ST_CoordinateUnqualified = gooxml.Int64(0)
|
||||
anchor.PositionH.RelativeFromAttr = wd.ST_RelFromHPage
|
||||
anchor.PositionH.Choice = &wd.CT_PosHChoice{}
|
||||
anchor.PositionH.RelativeFromAttr = wml.WdST_RelFromHPage
|
||||
anchor.PositionH.Choice = &wml.WdCT_PosHChoice{}
|
||||
anchor.PositionH.Choice.PosOffset = gooxml.Int32(0)
|
||||
|
||||
anchor.PositionV.RelativeFromAttr = wd.ST_RelFromVPage
|
||||
anchor.PositionV.Choice = &wd.CT_PosVChoice{}
|
||||
anchor.PositionV.RelativeFromAttr = wml.WdST_RelFromVPage
|
||||
anchor.PositionV.Choice = &wml.WdCT_PosVChoice{}
|
||||
anchor.PositionV.Choice.PosOffset = gooxml.Int32(0)
|
||||
|
||||
anchor.Extent.CxAttr = int64(float64(img.img.Size.X*measurement.Pixel72) / measurement.EMU)
|
||||
anchor.Extent.CyAttr = int64(float64(img.img.Size.Y*measurement.Pixel72) / measurement.EMU)
|
||||
anchor.Choice = &wd.EG_WrapTypeChoice{}
|
||||
anchor.Choice.WrapSquare = wd.NewCT_WrapSquare()
|
||||
anchor.Choice.WrapSquare.WrapTextAttr = wd.ST_WrapTextBothSides
|
||||
anchor.Choice = &wml.WdEG_WrapTypeChoice{}
|
||||
anchor.Choice.WrapSquare = wml.NewWdCT_WrapSquare()
|
||||
anchor.Choice.WrapSquare.WrapTextAttr = wml.WdST_WrapTextBothSides
|
||||
|
||||
// Mac Word chokes if the ID is greater than an int32, even though the field is a
|
||||
// uint32 in the XSD
|
||||
|
BIN
spreadsheet/testdata/simple-1.xlsx
vendored
BIN
spreadsheet/testdata/simple-1.xlsx
vendored
Binary file not shown.
BIN
spreadsheet/testdata/simple-2.xlsx
vendored
BIN
spreadsheet/testdata/simple-2.xlsx
vendored
Binary file not shown.
2
spreadsheet/testdata/styles.xml
vendored
2
spreadsheet/testdata/styles.xml
vendored
@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<x:styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:sh="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:xml="http://www.w3.org/XML/1998/namespace"><x:fonts count="2"><x:font><x:name val="Calibri"/><x:family val="2"/><x:color theme="1"/><x:sz val="12"/><x:scheme val="minor"/></x:font><x:font><x:name val="Calibri"/><x:family val="2"/><x:b/><x:color theme="1"/><x:sz val="12"/><x:scheme val="minor"/></x:font></x:fonts><x:fills count="2"><x:fill><x:patternFill patternType="none"/></x:fill><x:fill><x:patternFill patternType="gray125"/></x:fill></x:fills><x:borders count="1"><x:border><x:left/><x:right/><x:top/><x:bottom/><x:diagonal/></x:border></x:borders><x:cellStyleXfs count="1"><x:xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></x:cellStyleXfs><x:cellXfs count="2"><x:xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><x:xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/></x:cellXfs><x:cellStyles count="1"><x:cellStyle name="Normal" xfId="0" builtinId="0"/></x:cellStyles><x:dxfs count="0"/><x:tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium7"/><x:extLst><x:ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"/></x:extLst></x:styleSheet>
|
||||
<ma:styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:ma="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:s="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:xml="http://www.w3.org/XML/1998/namespace"><ma:fonts count="2"><ma:font><ma:name val="Calibri"/><ma:family val="2"/><ma:color theme="1"/><ma:sz val="12"/><ma:scheme val="minor"/></ma:font><ma:font><ma:name val="Calibri"/><ma:family val="2"/><ma:b/><ma:color theme="1"/><ma:sz val="12"/><ma:scheme val="minor"/></ma:font></ma:fonts><ma:fills count="2"><ma:fill><ma:patternFill patternType="none"/></ma:fill><ma:fill><ma:patternFill patternType="gray125"/></ma:fill></ma:fills><ma:borders count="1"><ma:border><ma:left/><ma:right/><ma:top/><ma:bottom/><ma:diagonal/></ma:border></ma:borders><ma:cellStyleXfs count="1"><ma:xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></ma:cellStyleXfs><ma:cellXfs count="2"><ma:xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><ma:xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/></ma:cellXfs><ma:cellStyles count="1"><ma:cellStyle name="Normal" xfId="0" builtinId="0"/></ma:cellStyles><ma:dxfs count="0"/><ma:tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium7"/><ma:extLst><ma:ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"/></ma:extLst></ma:styleSheet>
|
2
spreadsheet/testdata/workbook.xml
vendored
2
spreadsheet/testdata/workbook.xml
vendored
@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<x:workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:sh="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:xml="http://www.w3.org/XML/1998/namespace"><x:fileVersion appName="xl" lastEdited="6" lowestEdited="6" rupBuild="14420"/><x:workbookPr filterPrivacy="1" defaultThemeVersion="164011"/><x:bookViews><x:workbookView xWindow="0" yWindow="0" windowWidth="24960" windowHeight="10260"/></x:bookViews><x:sheets><x:sheet name="Sheet1" sheetId="1" r:id="rId1"/></x:sheets><x:calcPr calcId="162913"/><x:extLst><x:ext uri="{140A7094-0E35-4892-8432-C4D2E57EDEB5}"/></x:extLst></x:workbook>
|
||||
<ma:workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:ma="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:s="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:xml="http://www.w3.org/XML/1998/namespace"><ma:fileVersion appName="xl" lastEdited="6" lowestEdited="6" rupBuild="14420"/><ma:workbookPr filterPrivacy="1" defaultThemeVersion="164011"/><ma:bookViews><ma:workbookView xWindow="0" yWindow="0" windowWidth="24960" windowHeight="10260"/></ma:bookViews><ma:sheets><ma:sheet name="Sheet1" sheetId="1" r:id="rId1"/></ma:sheets><ma:calcPr calcId="162913"/><ma:extLst><ma:ext uri="{140A7094-0E35-4892-8432-C4D2E57EDEB5}"/></ma:extLst></ma:workbook>
|
2
spreadsheet/testdata/worksheet.xml
vendored
2
spreadsheet/testdata/worksheet.xml
vendored
@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<x:worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:sh="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:xml="http://www.w3.org/XML/1998/namespace"><x:dimension ref="A1"/><x:sheetViews><x:sheetView tabSelected="1" workbookViewId="0"><x:selection activeCell="I4" sqref="I4"/></x:sheetView></x:sheetViews><x:sheetFormatPr defaultRowHeight="15"/><x:sheetData/><x:pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/><x:pageSetup orientation="portrait" r:id="rId1"/></x:worksheet>
|
||||
<ma:worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:ma="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:s="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:xml="http://www.w3.org/XML/1998/namespace"><ma:dimension ref="A1"/><ma:sheetViews><ma:sheetView tabSelected="1" workbookViewId="0"><ma:selection activeCell="I4" sqref="I4"/></ma:sheetView></ma:sheetViews><ma:sheetFormatPr defaultRowHeight="15"/><ma:sheetData/><ma:pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/><ma:pageSetup orientation="portrait" r:id="rId1"/></ma:worksheet>
|
Loading…
x
Reference in New Issue
Block a user