Compare commits
2 Commits
0ee7abdf5d
...
a1c4002c5a
Author | SHA1 | Date | |
---|---|---|---|
a1c4002c5a | |||
32bedaf62d |
2
golang/.gitignore
vendored
Normal file
2
golang/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fusion.exe
|
||||||
|
fusion.doc
|
15
golang/Makefile
Normal file
15
golang/Makefile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
all: run
|
||||||
|
|
||||||
|
run: fusion.doc
|
||||||
|
|
||||||
|
fusion.doc: key.txt
|
||||||
|
UNIDOC_LICENSE_API_KEY=$(shell cat key.txt) go run .
|
||||||
|
|
||||||
|
build: fusion.exe
|
||||||
|
|
||||||
|
fusion.exe: key.txt
|
||||||
|
env UNIDOC_LICENSE_API_KEY=$(shell cat key.txt) GOOS=windows GOARCH=amd64 go build .
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f ./fusion.doc
|
||||||
|
rm -f ./fusion.exe
|
@ -9,16 +9,16 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gioui.org/app"
|
"gioui.org/app"
|
||||||
"gioui.org/font/gofont"
|
"gioui.org/font/gofont"
|
||||||
"gioui.org/op"
|
"gioui.org/layout"
|
||||||
"gioui.org/text"
|
"gioui.org/op"
|
||||||
"gioui.org/layout"
|
"gioui.org/text"
|
||||||
"gioui.org/unit"
|
"gioui.org/unit"
|
||||||
"gioui.org/widget"
|
"gioui.org/widget"
|
||||||
"gioui.org/widget/material"
|
"gioui.org/widget/material"
|
||||||
|
|
||||||
|
"github.com/unidoc/unioffice/common/license"
|
||||||
"github.com/unidoc/unioffice/document"
|
"github.com/unidoc/unioffice/document"
|
||||||
"github.com/unidoc/unioffice/common/license"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -33,7 +33,7 @@ func init() {
|
|||||||
func main() {
|
func main() {
|
||||||
go func() {
|
go func() {
|
||||||
w := new(app.Window)
|
w := new(app.Window)
|
||||||
w.Option(app.Title("Fusionner DOCX"), app.Size(unit.Dp(800), unit.Dp(600)))
|
w.Option(app.Title("Fusionner DOCX"), app.Size(unit.Dp(800), unit.Dp(600)))
|
||||||
if err := loop(w); err != nil {
|
if err := loop(w); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -43,23 +43,23 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loop(w *app.Window) error {
|
func loop(w *app.Window) error {
|
||||||
var ops op.Ops
|
var ops op.Ops
|
||||||
|
|
||||||
th := material.NewTheme()
|
th := material.NewTheme()
|
||||||
th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection()))
|
th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection()))
|
||||||
var input widget.Editor
|
var input widget.Editor
|
||||||
input.SingleLine = true
|
input.SingleLine = true
|
||||||
var button widget.Clickable
|
var button widget.Clickable
|
||||||
|
|
||||||
for {
|
for {
|
||||||
evt := w.Event()
|
evt := w.Event()
|
||||||
switch e := evt.(type) {
|
switch e := evt.(type) {
|
||||||
case app.DestroyEvent:
|
case app.DestroyEvent:
|
||||||
return e.Err
|
return e.Err
|
||||||
case app.FrameEvent:
|
case app.FrameEvent:
|
||||||
gtx := app.NewContext(&ops, e)
|
gtx := app.NewContext(&ops, e)
|
||||||
layout.Flex{
|
layout.Flex{
|
||||||
Axis: layout.Vertical,
|
Axis: layout.Vertical,
|
||||||
Alignment: layout.Middle,
|
Alignment: layout.Middle,
|
||||||
}.Layout(gtx,
|
}.Layout(gtx,
|
||||||
layout.Rigid(material.H1(th, "Sélectionner un dossier").Layout),
|
layout.Rigid(material.H1(th, "Sélectionner un dossier").Layout),
|
||||||
@ -92,7 +92,7 @@ func fusionnerDocx(dossier string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, fichier := range fichiers {
|
for _, fichier := range fichiers {
|
||||||
if filepath.Ext(fichier.Name()) == ".doc" {
|
if filepath.Ext(fichier.Name()) == ".docx" {
|
||||||
cheminFichier := filepath.Join(dossier, fichier.Name())
|
cheminFichier := filepath.Join(dossier, fichier.Name())
|
||||||
doc, err := document.Open(cheminFichier)
|
doc, err := document.Open(cheminFichier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -102,12 +102,12 @@ func fusionnerDocx(dossier string) {
|
|||||||
|
|
||||||
for _, para := range doc.Paragraphs() {
|
for _, para := range doc.Paragraphs() {
|
||||||
newPara := docFusionne.AddParagraph()
|
newPara := docFusionne.AddParagraph()
|
||||||
// newPara.Properties().SetAlignment(para.Properties().Alignment())
|
// newPara.Properties().SetAlignment(para.Properties().Alignment())
|
||||||
for _, run := range para.Runs() {
|
for _, run := range para.Runs() {
|
||||||
newRun := newPara.AddRun()
|
newRun := newPara.AddRun()
|
||||||
newRun.Properties().SetBold(run.Properties().IsBold())
|
newRun.Properties().SetBold(run.Properties().IsBold())
|
||||||
newRun.Properties().SetItalic(run.Properties().IsItalic())
|
newRun.Properties().SetItalic(run.Properties().IsItalic())
|
||||||
// newRun.Properties().SetUnderline(run.Properties().IsUnderline())
|
// newRun.Properties().SetUnderline(run.Properties().IsUnderline())
|
||||||
newRun.AddText(run.Text())
|
newRun.AddText(run.Text())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,4 +123,3 @@ func fusionnerDocx(dossier string) {
|
|||||||
|
|
||||||
fmt.Printf("Documents fusionnés dans %s\n", nomFichierSortie)
|
fmt.Printf("Documents fusionnés dans %s\n", nomFichierSortie)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user