Skip to content

Commit

Permalink
clean code for golint : change all func in IObj to private
Browse files Browse the repository at this point in the history
  • Loading branch information
oneplus1000 committed Jan 29, 2016
1 parent 4f7d079 commit 79235e7
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 95 deletions.
8 changes: 4 additions & 4 deletions basic_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ type BasicObj struct {
}

//Init : init BasicObj
func (b *BasicObj) Init(funcGetRoot func() *GoPdf) {
func (b *BasicObj) init(funcGetRoot func() *GoPdf) {
}

//Build : build buff
func (b *BasicObj) Build() error {
func (b *BasicObj) build() error {
b.buffer.WriteString(b.Data)
return nil
}

//GetType : type of object
func (b *BasicObj) GetType() string {
func (b *BasicObj) getType() string {
return "Basic"
}

//GetObjBuff : get buffer
func (b *BasicObj) GetObjBuff() *bytes.Buffer {
func (b *BasicObj) getObjBuff() *bytes.Buffer {
return &(b.buffer)
}
4 changes: 4 additions & 0 deletions buff_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gopdf

import "io"

//WriteUInt32 writes a 32-bit unsigned integer value to w io.Writer
func WriteUInt32(w io.Writer, v uint) error {
a := byte(v >> 24)
b := byte(v >> 16)
Expand All @@ -14,6 +15,7 @@ func WriteUInt32(w io.Writer, v uint) error {
return nil
}

//WriteUInt16 writes a 16-bit unsigned integer value to w io.Writer
func WriteUInt16(w io.Writer, v uint) error {

a := byte(v >> 8)
Expand All @@ -25,6 +27,7 @@ func WriteUInt16(w io.Writer, v uint) error {
return nil
}

//WriteTag writes string value to w io.Writer
func WriteTag(w io.Writer, tag string) error {
b := []byte(tag)
_, err := w.Write(b)
Expand All @@ -34,6 +37,7 @@ func WriteTag(w io.Writer, tag string) error {
return nil
}

//WriteBytes writes []byte value to w io.Writer
func WriteBytes(w io.Writer, data []byte, offset int, count int) error {

_, err := w.Write(data[offset : offset+count])
Expand Down
11 changes: 6 additions & 5 deletions catalog_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ import (
//"fmt"
)

//CatalogObj : catalog dictionary
type CatalogObj struct { //impl IObj
buffer bytes.Buffer
}

func (c *CatalogObj) Init(funcGetRoot func() *GoPdf) {
func (c *CatalogObj) init(funcGetRoot func() *GoPdf) {

}

func (c *CatalogObj) Build() error {
func (c *CatalogObj) build() error {
c.buffer.WriteString("<<\n")
c.buffer.WriteString(" /Type /" + c.GetType() + "\n")
c.buffer.WriteString(" /Type /" + c.getType() + "\n")
c.buffer.WriteString(" /Pages 2 0 R\n")
c.buffer.WriteString(">>\n")
return nil
}

func (c *CatalogObj) GetType() string {
func (c *CatalogObj) getType() string {
return "Catalog"
}

func (c *CatalogObj) GetObjBuff() *bytes.Buffer {
func (c *CatalogObj) getObjBuff() *bytes.Buffer {
return &(c.buffer)
}
8 changes: 4 additions & 4 deletions cid_font_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ type CIDFontObj struct {
indexObjSubfontDescriptor int
}

func (ci *CIDFontObj) Init(funcGetRoot func() *GoPdf) {
func (ci *CIDFontObj) init(funcGetRoot func() *GoPdf) {
}

func (ci *CIDFontObj) Build() error {
func (ci *CIDFontObj) build() error {

ci.buffer.WriteString("<<\n")
ci.buffer.WriteString(fmt.Sprintf("/BaseFont /%s\n", CreateEmbeddedFontSubsetName(ci.PtrToSubsetFontObj.GetFamily())))
Expand Down Expand Up @@ -42,11 +42,11 @@ func (ci *CIDFontObj) SetIndexObjSubfontDescriptor(index int) {
ci.indexObjSubfontDescriptor = index
}

func (ci *CIDFontObj) GetType() string {
func (ci *CIDFontObj) getType() string {
return "CIDFont"
}

func (ci *CIDFontObj) GetObjBuff() *bytes.Buffer {
func (ci *CIDFontObj) getObjBuff() *bytes.Buffer {
//fmt.Printf("%s\n", me.buffer.String())
return &ci.buffer
}
Expand Down
9 changes: 4 additions & 5 deletions content_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ type ContentObj struct { //impl IObj
getRoot func() *GoPdf
}

func (c *ContentObj) Init(funcGetRoot func() *GoPdf) {
func (c *ContentObj) init(funcGetRoot func() *GoPdf) {
c.getRoot = funcGetRoot
}

func (c *ContentObj) Build() error {
func (c *ContentObj) build() error {
streamlen := c.stream.Len()
c.buffer.WriteString("<<\n")
c.buffer.WriteString("/Length " + strconv.Itoa(streamlen) + "\n")
Expand All @@ -30,11 +30,11 @@ func (c *ContentObj) Build() error {
return nil
}

func (c *ContentObj) GetType() string {
func (c *ContentObj) getType() string {
return "Content"
}

func (c *ContentObj) GetObjBuff() *bytes.Buffer {
func (c *ContentObj) getObjBuff() *bytes.Buffer {
return &(c.buffer)
}

Expand Down Expand Up @@ -188,7 +188,6 @@ func (c *ContentObj) AppendStreamSetLineType(t string) {
c.stream.WriteString(fmt.Sprint("[] 0 d\n"))
}


}

// Set the grayscale fills
Expand Down
8 changes: 4 additions & 4 deletions embedfont_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ type EmbedFontObj struct {
font IFont
}

func (e *EmbedFontObj) Init(funcGetRoot func() *GoPdf) {
func (e *EmbedFontObj) init(funcGetRoot func() *GoPdf) {
}

func (e *EmbedFontObj) Build() error {
func (e *EmbedFontObj) build() error {
b, err := ioutil.ReadFile(e.zfontpath)
if err != nil {
return err
Expand All @@ -31,11 +31,11 @@ func (e *EmbedFontObj) Build() error {
return nil
}

func (e *EmbedFontObj) GetType() string {
func (e *EmbedFontObj) getType() string {
return "EmbedFont"
}

func (e *EmbedFontObj) GetObjBuff() *bytes.Buffer {
func (e *EmbedFontObj) getObjBuff() *bytes.Buffer {
return &(e.buffer)
}

Expand Down
8 changes: 4 additions & 4 deletions encoding_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ type EncodingObj struct {
font IFont
}

func (e *EncodingObj) Init(funcGetRoot func() *GoPdf) {
func (e *EncodingObj) init(funcGetRoot func() *GoPdf) {

}
func (e *EncodingObj) GetType() string {
func (e *EncodingObj) getType() string {
return "Encoding"
}
func (e *EncodingObj) GetObjBuff() *bytes.Buffer {
func (e *EncodingObj) getObjBuff() *bytes.Buffer {
return &e.buffer
}
func (e *EncodingObj) Build() error {
func (e *EncodingObj) build() error {
e.buffer.WriteString("<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [")
e.buffer.WriteString(e.font.GetDiff())
e.buffer.WriteString("]>>\n")
Expand Down
10 changes: 5 additions & 5 deletions font_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ type FontObj struct { //impl IObj
CountOfFont int
}

func (f *FontObj) Init(funcGetRoot func() *GoPdf) {
func (f *FontObj) init(funcGetRoot func() *GoPdf) {
f.IsEmbedFont = false
//me.CountOfFont = -1
}

func (f *FontObj) Build() error {
func (f *FontObj) build() error {

baseFont := f.Family
if f.Font != nil {
baseFont = f.Font.GetName()
}

f.buffer.WriteString("<<\n")
f.buffer.WriteString(" /Type /" + f.GetType() + "\n")
f.buffer.WriteString(" /Type /" + f.getType() + "\n")
f.buffer.WriteString(" /Subtype /TrueType\n")
f.buffer.WriteString(" /BaseFont /" + baseFont + "\n")
if f.IsEmbedFont {
Expand All @@ -46,11 +46,11 @@ func (f *FontObj) Build() error {
return nil
}

func (f *FontObj) GetType() string {
func (f *FontObj) getType() string {
return "Font"
}

func (f *FontObj) GetObjBuff() *bytes.Buffer {
func (f *FontObj) getObjBuff() *bytes.Buffer {
return &(f.buffer)
}

Expand Down
10 changes: 5 additions & 5 deletions fontdescriptor_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ type FontDescriptorObj struct {
fontFileObjRelate string
}

func (f *FontDescriptorObj) Init(funcGetRoot func() *GoPdf) {
func (f *FontDescriptorObj) init(funcGetRoot func() *GoPdf) {

}

func (f *FontDescriptorObj) Build() error {
func (f *FontDescriptorObj) build() error {

f.buffer.WriteString("<</Type /FontDescriptor /FontName /" + f.font.GetName() + " ")
descs := f.font.GetDesc()
Expand All @@ -25,7 +25,7 @@ func (f *FontDescriptorObj) Build() error {
i++
}

if f.GetType() == "Type1" {
if f.getType() == "Type1" {
f.buffer.WriteString("/FontFile ")
} else {
f.buffer.WriteString("/FontFile2 ")
Expand All @@ -37,11 +37,11 @@ func (f *FontDescriptorObj) Build() error {
return nil
}

func (f *FontDescriptorObj) GetType() string {
func (f *FontDescriptorObj) getType() string {
return "FontDescriptor"
}

func (f *FontDescriptorObj) GetObjBuff() *bytes.Buffer {
func (f *FontDescriptorObj) getObjBuff() *bytes.Buffer {
return &(f.buffer)
}

Expand Down
Loading

0 comments on commit 79235e7

Please sign in to comment.