From 2f9f76f1dc6de5062eab2370513a5890c75f81ca 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:07:16 +0800 Subject: [PATCH] rename package to docx --- .golangci.yml | 2 +- apidrawing.go | 2 +- apilink.go | 2 +- apipara.go | 2 +- apirun.go | 2 +- apitable.go | 2 +- apitext.go | 2 +- cmd/main/main.go | 26 +++++++++++++------------- docxlib.go | 4 ++-- empty.go | 2 +- fs.go | 2 +- go.mod | 2 +- helper.go | 2 +- image.go | 2 +- link.go | 2 +- media.go | 2 +- pack.go | 2 +- slice.go | 2 +- structdoc.go | 2 +- structdoc_test.go | 2 +- structdrawing.go | 2 +- structdrawing_test.go | 2 +- structlink.go | 2 +- structpara.go | 2 +- structrel.go | 2 +- structrel_test.go | 2 +- structrun.go | 2 +- structtable.go | 2 +- structtable_test.go | 2 +- structtext.go | 2 +- unpack.go | 2 +- 31 files changed, 44 insertions(+), 44 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index bda3f4e..5a34144 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ linters-settings: ignoretests: true goimports: - local-prefixes: github.com/fumiama/docxlib + local-prefixes: github.com/fumiama/go-docx forbidigo: # Forbid the following identifiers diff --git a/apidrawing.go b/apidrawing.go index c42d4d1..aca3abd 100644 --- a/apidrawing.go +++ b/apidrawing.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "bytes" diff --git a/apilink.go b/apilink.go index e853e35..7ab24ee 100644 --- a/apilink.go +++ b/apilink.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx //nolint:revive,stylecheck const ( diff --git a/apipara.go b/apipara.go index dc64074..668fe5f 100644 --- a/apipara.go +++ b/apipara.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import "unsafe" diff --git a/apirun.go b/apirun.go index 3a2f0f2..8a1014e 100644 --- a/apirun.go +++ b/apirun.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx // Color allows to set run color func (r *Run) Color(color string) *Run { diff --git a/apitable.go b/apitable.go index 384e9b7..3dfa362 100644 --- a/apitable.go +++ b/apitable.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import "unsafe" diff --git a/apitext.go b/apitext.go index cbdb6c6..975615a 100644 --- a/apitext.go +++ b/apitext.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import "strings" diff --git a/cmd/main/main.go b/cmd/main/main.go index 07793fc..7756b6b 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -27,7 +27,7 @@ import ( "os" "strings" - "github.com/fumiama/docxlib" + "github.com/fumiama/go-docx" ) func main() { @@ -35,21 +35,21 @@ func main() { analyzeOnly := flag.Bool("a", false, "analyze file only") unm := flag.Bool("u", false, "lease unmarshalled file") flag.Parse() - var w *docxlib.Docx + var w *docx.Docx if !*analyzeOnly { fmt.Printf("Preparing new document to write at %s\n", *fileLocation) - w = docxlib.NewA4() + w = docx.NewA4() // add new paragraph para1 := w.AddParagraph().Justification("distribute") r, err := para1.AddAnchorDrawingFrom("testdata/fumiama.JPG") if err != nil { panic(err) } - r.Children[0].(*docxlib.Drawing).Anchor.Size(r.Children[0].(*docxlib.Drawing).Anchor.Extent.CX/4, r.Children[0].(*docxlib.Drawing).Anchor.Extent.CY/4) - r.Children[0].(*docxlib.Drawing).Anchor.BehindDoc = 1 - r.Children[0].(*docxlib.Drawing).Anchor.PositionH.PosOffset = r.Children[0].(*docxlib.Drawing).Anchor.Extent.CX - r.Children[0].(*docxlib.Drawing).Anchor.Graphic.GraphicData.Pic.BlipFill.Blip.AlphaModFix = &docxlib.AAlphaModFix{Amount: 50000} + r.Children[0].(*docx.Drawing).Anchor.Size(r.Children[0].(*docx.Drawing).Anchor.Extent.CX/4, r.Children[0].(*docx.Drawing).Anchor.Extent.CY/4) + r.Children[0].(*docx.Drawing).Anchor.BehindDoc = 1 + r.Children[0].(*docx.Drawing).Anchor.PositionH.PosOffset = r.Children[0].(*docx.Drawing).Anchor.Extent.CX + r.Children[0].(*docx.Drawing).Anchor.Graphic.GraphicData.Pic.BlipFill.Blip.AlphaModFix = &docx.AAlphaModFix{Amount: 50000} // add text para1.AddText("test") para1.AddText("test font size").Size("44") @@ -70,13 +70,13 @@ func main() { if err != nil { panic(err) } - r.Children[0].(*docxlib.Drawing).Inline.Size(r.Children[0].(*docxlib.Drawing).Inline.Extent.CX*4/5, r.Children[0].(*docxlib.Drawing).Inline.Extent.CY*4/5) + r.Children[0].(*docx.Drawing).Inline.Size(r.Children[0].(*docx.Drawing).Inline.Extent.CX*4/5, r.Children[0].(*docx.Drawing).Inline.Extent.CY*4/5) para4.AddTab().AddTab() r, err = para4.AddInlineDrawingFrom("testdata/fumiama2x.webp") if err != nil { panic(err) } - r.Children[0].(*docxlib.Drawing).Inline.Size(r.Children[0].(*docxlib.Drawing).Inline.Extent.CX*4/5, r.Children[0].(*docxlib.Drawing).Inline.Extent.CY*4/5) + r.Children[0].(*docx.Drawing).Inline.Size(r.Children[0].(*docx.Drawing).Inline.Extent.CX*4/5, r.Children[0].(*docx.Drawing).Inline.Extent.CY*4/5) para5 := w.AddParagraph().Justification("center") // add text @@ -101,7 +101,7 @@ func main() { for x, r := range tbl2.TableRows { r.Justification("center") for y, c := range r.TableCells { - c.TableCellProperties.VAlign = &docxlib.WVerticalAlignment{Val: "center"} + c.TableCellProperties.VAlign = &docx.WVerticalAlignment{Val: "center"} c.AddParagraph().Justification("center").AddText(fmt.Sprintf("(%d, %d)", x, y)) } } @@ -131,7 +131,7 @@ func main() { panic(err) } size := fileinfo.Size() - doc, err := docxlib.Parse(readFile, size) + doc, err := docx.Parse(readFile, size) if err != nil { panic(err) } @@ -154,9 +154,9 @@ func main() { fmt.Println("Plain text:") for _, it := range doc.Document.Body.Items { switch para := it.(type) { - case docxlib.Paragraph: + case docx.Paragraph: fmt.Println(para.String()) - case docxlib.WTable: + case docx.WTable: fmt.Println("------------------------------") for x, r := range para.TableRows { fmt.Printf("[%d] ", x) diff --git a/docxlib.go b/docxlib.go index 87bb3ab..4d855d6 100644 --- a/docxlib.go +++ b/docxlib.go @@ -18,9 +18,9 @@ along with this program. If not, see . */ -// Package docxlib is one of the most functional libraries to read and write .docx +// package docx is one of the most functional libraries to read and write .docx // (a.k.a. Microsoft Word documents or ECMA-376 Office Open XML) files in Go. -package docxlib +package docx import ( "archive/zip" diff --git a/empty.go b/empty.go index a3fc12f..a616dfc 100644 --- a/empty.go +++ b/empty.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "bytes" diff --git a/fs.go b/fs.go index ac39bf3..bfbf6a2 100644 --- a/fs.go +++ b/fs.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import "embed" diff --git a/go.mod b/go.mod index 96957da..abedea5 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/fumiama/docxlib +module github.com/fumiama/go-docx go 1.18 diff --git a/helper.go b/helper.go index cece7ec..a3dd925 100644 --- a/helper.go +++ b/helper.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "unsafe" diff --git a/image.go b/image.go index 33ce288..a58ab11 100644 --- a/image.go +++ b/image.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx // addImage add image to docx and return its rId func (f *Docx) addImage(m Media) string { diff --git a/link.go b/link.go index db50b53..46718f8 100644 --- a/link.go +++ b/link.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "errors" diff --git a/media.go b/media.go index e6c17ff..01acb24 100644 --- a/media.go +++ b/media.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx //nolint:revive,stylecheck const MEDIA_FOLDER = `word/media/` diff --git a/pack.go b/pack.go index 3f6dc36..5c96372 100644 --- a/pack.go +++ b/pack.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "archive/zip" diff --git a/slice.go b/slice.go index aba86b6..b866d69 100644 --- a/slice.go +++ b/slice.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import "unsafe" diff --git a/structdoc.go b/structdoc.go index 9c91676..6d60136 100644 --- a/structdoc.go +++ b/structdoc.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/structdoc_test.go b/structdoc_test.go index 15523d9..41a3446 100644 --- a/structdoc_test.go +++ b/structdoc_test.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/structdrawing.go b/structdrawing.go index 19c22d5..b23ce3f 100644 --- a/structdrawing.go +++ b/structdrawing.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/structdrawing_test.go b/structdrawing_test.go index c4d32dc..3769efc 100644 --- a/structdrawing_test.go +++ b/structdrawing_test.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/structlink.go b/structlink.go index 2d244a3..05eae10 100644 --- a/structlink.go +++ b/structlink.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/structpara.go b/structpara.go index 6d35e63..a72077f 100644 --- a/structpara.go +++ b/structpara.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "crypto/md5" diff --git a/structrel.go b/structrel.go index da3dc09..547e63d 100644 --- a/structrel.go +++ b/structrel.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx //nolint:revive,stylecheck const ( diff --git a/structrel_test.go b/structrel_test.go index 36606cf..dcc2716 100644 --- a/structrel_test.go +++ b/structrel_test.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "crypto/md5" diff --git a/structrun.go b/structrun.go index 8273828..4873610 100644 --- a/structrun.go +++ b/structrun.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/structtable.go b/structtable.go index 431d452..76199f0 100644 --- a/structtable.go +++ b/structtable.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/structtable_test.go b/structtable_test.go index cc6f9d7..1b61e48 100644 --- a/structtable_test.go +++ b/structtable_test.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/structtext.go b/structtext.go index 5a0156b..5478620 100644 --- a/structtext.go +++ b/structtext.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "encoding/xml" diff --git a/unpack.go b/unpack.go index fe9e0c3..d30600d 100644 --- a/unpack.go +++ b/unpack.go @@ -18,7 +18,7 @@ along with this program. If not, see . */ -package docxlib +package docx import ( "archive/zip"