Browse Source

добавил стиль таблицы в demo
баг фикс записи перевода строк

kpmy 10 years ago
parent
commit
3a4e46a9ad
2 changed files with 7 additions and 0 deletions
  1. 3 0
      demo/report.go
  2. 4 0
      mappers/para.go

+ 3 - 0
demo/report.go

@@ -4,6 +4,7 @@ import (
 	"bytes"
 	"github.com/kpmy/golorem"
 	"github.com/kpmy/ypk/assert"
+	"image/color"
 	"io"
 	"math/rand"
 	"odf/generators"
@@ -12,6 +13,7 @@ import (
 	"odf/model"
 	_ "odf/model/stub" // необходимо
 	"odf/xmlns"
+	"odf/xmlns/fo"
 	"os"
 	"runtime"
 	"strconv"
@@ -52,6 +54,7 @@ func report(suffix string, fm *mappers.Formatter) {
 		fm.SetAttr(new(attr.TextAttributes).Bold().Size(18))
 		fm.WritePara("TABLE 50x5")
 		fm.SetAttr(nil)
+		fm.SetAttr(new(attr.TableCellAttributes).Border(attr.Border{Width: 0.01, Color: color.Black, Style: fo.Solid}))
 		tm := &mappers.TableMapper{}
 		tm.ConnectTo(fm)
 		tm.Write("test", 50+1, 5) //50+header row

+ 4 - 0
mappers/para.go

@@ -91,6 +91,10 @@ func (p *ParaMapper) WriteString(_s string) {
 				p.fm.attr.Fit(text.Span, func(a attr.Attributes) {
 					p.rider.Pos(p.rider.Pos().Parent())
 				})
+				//skip cr+lf
+				if pos+1 < len(s) && s[pos+1] == '\n' {
+					pos = pos + 1
+				}
 				for pos = pos + 1; pos < len(s); pos++ {
 					buf = append(buf, s[pos])
 				}