From 32bedaf62d3b9de43ba2705d6fb10e874a50d052 Mon Sep 17 00:00:00 2001 From: Olivier DOSSMANN Date: Thu, 18 Jul 2024 09:55:34 +0200 Subject: [PATCH] fix(Project): Make it runs more easily --- golang/.gitignore | 2 ++ golang/Makefile | 15 +++++++++++++++ golang/main.go | 35 +++++++++++++++++------------------ 3 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 golang/.gitignore create mode 100644 golang/Makefile diff --git a/golang/.gitignore b/golang/.gitignore new file mode 100644 index 0000000..0b61726 --- /dev/null +++ b/golang/.gitignore @@ -0,0 +1,2 @@ +fusion.exe +fusion.doc diff --git a/golang/Makefile b/golang/Makefile new file mode 100644 index 0000000..5689c4f --- /dev/null +++ b/golang/Makefile @@ -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 diff --git a/golang/main.go b/golang/main.go index 1fa8457..54f4b32 100644 --- a/golang/main.go +++ b/golang/main.go @@ -9,16 +9,16 @@ import ( "strings" "gioui.org/app" - "gioui.org/font/gofont" - "gioui.org/op" - "gioui.org/text" - "gioui.org/layout" - "gioui.org/unit" + "gioui.org/font/gofont" + "gioui.org/layout" + "gioui.org/op" + "gioui.org/text" + "gioui.org/unit" "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/common/license" ) func init() { @@ -33,7 +33,7 @@ func init() { func main() { go func() { 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 { log.Fatal(err) } @@ -43,23 +43,23 @@ func main() { } func loop(w *app.Window) error { - var ops op.Ops + var ops op.Ops - th := material.NewTheme() - th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection())) + th := material.NewTheme() + th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection())) var input widget.Editor input.SingleLine = true - var button widget.Clickable + var button widget.Clickable for { - evt := w.Event() - switch e := evt.(type) { + evt := w.Event() + switch e := evt.(type) { case app.DestroyEvent: return e.Err case app.FrameEvent: gtx := app.NewContext(&ops, e) layout.Flex{ - Axis: layout.Vertical, + Axis: layout.Vertical, Alignment: layout.Middle, }.Layout(gtx, layout.Rigid(material.H1(th, "Sélectionner un dossier").Layout), @@ -102,12 +102,12 @@ func fusionnerDocx(dossier string) { for _, para := range doc.Paragraphs() { newPara := docFusionne.AddParagraph() -// newPara.Properties().SetAlignment(para.Properties().Alignment()) + // newPara.Properties().SetAlignment(para.Properties().Alignment()) for _, run := range para.Runs() { newRun := newPara.AddRun() newRun.Properties().SetBold(run.Properties().IsBold()) newRun.Properties().SetItalic(run.Properties().IsItalic()) -// newRun.Properties().SetUnderline(run.Properties().IsUnderline()) + // newRun.Properties().SetUnderline(run.Properties().IsUnderline()) newRun.AddText(run.Text()) } } @@ -123,4 +123,3 @@ func fusionnerDocx(dossier string) { fmt.Printf("Documents fusionnés dans %s\n", nomFichierSortie) } -