1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-04 23:30:25 +08:00

rename package to docx

This commit is contained in:
源文雨
2023-02-26 13:07:16 +08:00
parent fafd4c9fc3
commit 2f9f76f1dc
31 changed files with 44 additions and 44 deletions

View File

@@ -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

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"bytes"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
//nolint:revive,stylecheck
const (

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import "unsafe"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
// Color allows to set run color
func (r *Run) Color(color string) *Run {

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import "unsafe"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import "strings"

View File

@@ -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)

View File

@@ -18,9 +18,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// 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"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"bytes"

2
fs.go
View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import "embed"

2
go.mod
View File

@@ -1,4 +1,4 @@
module github.com/fumiama/docxlib
module github.com/fumiama/go-docx
go 1.18

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"unsafe"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
// addImage add image to docx and return its rId
func (f *Docx) addImage(m Media) string {

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"errors"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
//nolint:revive,stylecheck
const MEDIA_FOLDER = `word/media/`

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"archive/zip"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import "unsafe"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"crypto/md5"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
//nolint:revive,stylecheck
const (

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"crypto/md5"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"encoding/xml"

View File

@@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package docxlib
package docx
import (
"archive/zip"