From 9f0df8945d55b81a96e0da4a6e9d7086911403c5 Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Sun, 9 Dec 2018 21:37:27 +0200 Subject: [PATCH] don't use XXX for TODOs --- pdf/contentstream/encoding.go | 2 +- pdf/contentstream/inline-image.go | 2 +- pdf/core/crypt.go | 2 +- pdf/core/encoding.go | 4 ++-- pdf/creator/block.go | 4 ++-- pdf/creator/creator_test.go | 2 +- pdf/creator/image.go | 2 +- pdf/creator/paragraph.go | 16 ++++++++-------- pdf/creator/styled_paragraph.go | 18 +++++++++--------- pdf/creator/table.go | 2 +- pdf/extractor/text.go | 2 +- pdf/internal/textencoding/glyphs_glyphlist.go | 16 ++++++++-------- pdf/model/font.go | 2 +- pdf/model/fontfile.go | 4 ++-- pdf/model/fonts/ttfparser.go | 4 ++-- pdf/model/functions_test.go | 4 ++-- pdf/model/image.go | 2 +- pdf/model/outlines.go | 4 ++-- pdf/model/page.go | 2 +- pdf/model/reader.go | 2 +- pdf/model/signature.go | 2 +- pdf/model/writer.go | 2 +- pdf/ps/parser.go | 2 +- 23 files changed, 51 insertions(+), 51 deletions(-) diff --git a/pdf/contentstream/encoding.go b/pdf/contentstream/encoding.go index 7de12745..e2bea7b6 100644 --- a/pdf/contentstream/encoding.go +++ b/pdf/contentstream/encoding.go @@ -360,7 +360,7 @@ func newMultiEncoderFromInlineImage(inlineImage *ContentStreamInlineImage) (*cor } if *name == core.StreamEncodingFilterNameFlate || *name == "Fl" { - // XXX: need to separate out the DecodeParms.. + // TODO: need to separate out the DecodeParms.. encoder, err := newFlateEncoderFromInlineImage(inlineImage, dParams) if err != nil { return nil, err diff --git a/pdf/contentstream/inline-image.go b/pdf/contentstream/inline-image.go index 47d4d6b2..a38487c7 100644 --- a/pdf/contentstream/inline-image.go +++ b/pdf/contentstream/inline-image.go @@ -63,7 +63,7 @@ func NewInlineImageFromImage(img model.Image, encoder core.StreamEncoder) (*Cont if filterName != core.StreamEncodingFilterNameRaw { inlineImage.Filter = core.MakeName(filterName) } - // XXX/FIXME: Add decode params? + // FIXME: Add decode params? return &inlineImage, nil } diff --git a/pdf/core/crypt.go b/pdf/core/crypt.go index 3402d4b0..2e255915 100644 --- a/pdf/core/crypt.go +++ b/pdf/core/crypt.go @@ -315,7 +315,7 @@ func (crypt *PdfCrypt) loadCryptFilters(ed *PdfObjectDictionary) error { crypt.cryptFilters = cryptFilters{} obj := ed.Get("CF") - obj = TraceToDirectObject(obj) // XXX may need to resolve reference... + obj = TraceToDirectObject(obj) // TODO: may need to resolve reference... if ref, isRef := obj.(*PdfObjectReference); isRef { o, err := crypt.parser.LookupByReference(*ref) if err != nil { diff --git a/pdf/core/encoding.go b/pdf/core/encoding.go index 151c19e6..eea359c7 100644 --- a/pdf/core/encoding.go +++ b/pdf/core/encoding.go @@ -974,7 +974,7 @@ func (this *DCTEncoder) DecodeBytes(encoded []byte) ([]byte, error) { // indicates that either the jpeg package is converting the raw // data into YCbCr with some kind of mapping, or that the original // data is not in R,G,B... - // XXX: This is not good as it means we end up with R, G, B... even + // TODO: This is not good as it means we end up with R, G, B... even // if the original colormap was different. Unless calling the RGBA() // call exactly reverses the previous conversion to YCbCr (even if // real data is not rgb)... ? @@ -1716,7 +1716,7 @@ func newMultiEncoderFromStream(streamObj *PdfObjectStream) (*MultiEncoder, error common.Log.Trace("Next name: %s, dp: %v, dParams: %v", *name, dp, dParams) if *name == StreamEncodingFilterNameFlate { - // XXX: need to separate out the DecodeParms.. + // TODO: need to separate out the DecodeParms.. encoder, err := newFlateEncoderFromStream(streamObj, dParams) if err != nil { return nil, err diff --git a/pdf/creator/block.go b/pdf/creator/block.go index 65b5d5d0..bb49986d 100644 --- a/pdf/creator/block.go +++ b/pdf/creator/block.go @@ -135,7 +135,7 @@ func (blk *Block) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, er cc.Translate(ctx.X, ctx.PageHeight-ctx.Y-blk.height) if blk.angle != 0 { // Make the rotation about the upper left corner. - // XXX/TODO: Account for rotation origin. (Consider). + // TODO: Account for rotation origin. (Consider). cc.Translate(0, blk.Height()) cc.RotateDeg(blk.angle) cc.Translate(0, -blk.Height()) @@ -154,7 +154,7 @@ func (blk *Block) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, er cc.Translate(blk.xPos, ctx.PageHeight-blk.yPos-blk.height) if blk.angle != 0 { // Make the rotation about the upper left corner. - // XXX/TODO: Consider supporting specification of rotation origin. + // TODO: Consider supporting specification of rotation origin. cc.Translate(0, blk.Height()) cc.RotateDeg(blk.angle) cc.Translate(0, -blk.Height()) diff --git a/pdf/creator/creator_test.go b/pdf/creator/creator_test.go index 0bd42e6f..aa0b368f 100644 --- a/pdf/creator/creator_test.go +++ b/pdf/creator/creator_test.go @@ -44,7 +44,7 @@ const testRobotoRegularTTFFile = "./testdata/roboto/Roboto-Regular.ttf" const testRobotoBoldTTFFile = "./testdata/roboto/Roboto-Bold.ttf" const testWts11TTFFile = "./testdata/wts11.ttf" -// XXX(peterwilliams97): /tmp/2_p_multi.pdf which is created in this test gives an error message +// TODO(peterwilliams97): /tmp/2_p_multi.pdf which is created in this test gives an error message // when opened in Adobe Reader: The font FreeSans contains bad Widths. // This problem did not occur when I replaced FreeSans.ttf with LiberationSans-Regular.ttf const testFreeSansTTFFile = "./testdata/FreeSans.ttf" diff --git a/pdf/creator/image.go b/pdf/creator/image.go index 1ec898af..7bcde067 100644 --- a/pdf/creator/image.go +++ b/pdf/creator/image.go @@ -212,7 +212,7 @@ func (img *Image) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, er // Absolute drawing should not affect context. ctx = origCtx } else { - // XXX/TODO: Use projected height. + // TODO: Use projected height. ctx.Y += img.margins.bottom ctx.Height -= img.margins.bottom } diff --git a/pdf/creator/paragraph.go b/pdf/creator/paragraph.go index fe2f18ce..f953901b 100644 --- a/pdf/creator/paragraph.go +++ b/pdf/creator/paragraph.go @@ -217,7 +217,7 @@ func (p *Paragraph) getTextWidth() float64 { glyph, found := p.textFont.Encoder().RuneToGlyph(r) if !found { common.Log.Debug("ERROR: Glyph not found for rune: 0x%04x=%c", r, r) - return -1 // XXX/FIXME: return error. + return -1 // FIXME: return error. } // Ignore newline for this.. Handles as if all in one line. @@ -228,7 +228,7 @@ func (p *Paragraph) getTextWidth() float64 { metrics, found := p.textFont.GetGlyphCharMetrics(glyph) if !found { common.Log.Debug("ERROR: Glyph char metrics not found! %q (rune 0x%04x=%c)", glyph, r, r) - return -1 // XXX/FIXME: return error. + return -1 // FIXME: return error. } w += p.fontSize * metrics.Wx } @@ -243,7 +243,7 @@ func (p *Paragraph) getTextLineWidth(line string) float64 { glyph, found := p.textFont.Encoder().RuneToGlyph(r) if !found { common.Log.Debug("ERROR: Glyph not found for rune: 0x%04x=%c", r, r) - return -1 // XXX/FIXME: return error. + return -1 // FIXME: return error. } // Ignore newline for this.. Handles as if all in one line. @@ -254,7 +254,7 @@ func (p *Paragraph) getTextLineWidth(line string) float64 { metrics, found := p.textFont.GetGlyphCharMetrics(glyph) if !found { common.Log.Debug("ERROR: Glyph char metrics not found! %q (rune 0x%04x=%c)", glyph, r, r) - return -1 // XXX/FIXME: return error. + return -1 // FIXME: return error. } width += p.fontSize * metrics.Wx @@ -281,7 +281,7 @@ func (p *Paragraph) getMaxLineWidth() float64 { } // Simple algorithm to wrap the text into lines (greedy algorithm - fill the lines). -// XXX/TODO: Consider the Knuth/Plass algorithm or an alternative. +// TODO: Consider the Knuth/Plass algorithm or an alternative. func (p *Paragraph) wrapText() error { if !p.enableWrap || int(p.wrapWidth) <= 0 { p.textLines = []string{p.text} @@ -331,7 +331,7 @@ func (p *Paragraph) wrapText() error { // Breaks on the character. idx := -1 for i := len(glyphs) - 1; i >= 0; i-- { - if glyphs[i] == "space" { // XXX: What about other space glyphs like controlHT? + if glyphs[i] == "space" { // TODO: What about other space glyphs like controlHT? idx = i break } @@ -396,7 +396,7 @@ func (p *Paragraph) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, if p.Height() > ctx.Height { // Goes out of the bounds. Write on a new template instead and create a new context at // upper left corner. - // XXX/TODO: Handle case when Paragraph is larger than the Page... + // TODO: Handle case when Paragraph is larger than the Page... // Should be fine if we just break on the paragraph, i.e. splitting it up over 2+ pages blocks = append(blocks, blk) @@ -541,7 +541,7 @@ func drawParagraphOnBlock(blk *Block, p *Paragraph, ctx DrawContext) (DrawContex return ctx, errors.New("Unsupported rune in text encoding") } - if glyph == "space" { // XXX: What about \t and other spaces. + if glyph == "space" { // TODO: What about \t and other spaces. if len(encoded) > 0 { objs = append(objs, core.MakeStringFromBytes(encoded)) encoded = []byte{} diff --git a/pdf/creator/styled_paragraph.go b/pdf/creator/styled_paragraph.go index da953da5..cf2c43d1 100644 --- a/pdf/creator/styled_paragraph.go +++ b/pdf/creator/styled_paragraph.go @@ -238,7 +238,7 @@ func (p *StyledParagraph) getTextWidth() float64 { if !found { common.Log.Debug("Error! Glyph not found for rune: %s\n", rune) - // XXX/FIXME: return error. + // FIXME: return error. return -1 } @@ -251,7 +251,7 @@ func (p *StyledParagraph) getTextWidth() float64 { if !found { common.Log.Debug("Glyph char metrics not found! %s\n", glyph) - // XXX/FIXME: return error. + // FIXME: return error. return -1 } @@ -273,7 +273,7 @@ func (p *StyledParagraph) getTextLineWidth(line []*TextChunk) float64 { if !found { common.Log.Debug("Error! Glyph not found for rune: %s\n", r) - // XXX/FIXME: return error. + // FIXME: return error. return -1 } @@ -286,7 +286,7 @@ func (p *StyledParagraph) getTextLineWidth(line []*TextChunk) float64 { if !found { common.Log.Debug("Glyph char metrics not found! %s\n", glyph) - // XXX/FIXME: return error. + // FIXME: return error. return -1 } @@ -329,7 +329,7 @@ func (p *StyledParagraph) getTextHeight() float64 { // wrapText splits text into lines. It uses a simple greedy algorithm to wrap // fill the lines. -// XXX/TODO: Consider the Knuth/Plass algorithm or an alternative. +// TODO: Consider the Knuth/Plass algorithm or an alternative. func (p *StyledParagraph) wrapText() error { if !p.enableWrap || int(p.wrapWidth) <= 0 { p.lines = [][]*TextChunk{p.chunks} @@ -362,7 +362,7 @@ func (p *StyledParagraph) wrapText() error { if !found { common.Log.Debug("Error! Glyph not found for rune: %v\n", r) - // XXX/FIXME: return error. + // FIXME: return error. return errors.New("Glyph not found for rune") } @@ -388,7 +388,7 @@ func (p *StyledParagraph) wrapText() error { if !found { common.Log.Debug("Glyph char metrics not found! %s\n", glyph) - // XXX/FIXME: return error. + // FIXME: return error. return errors.New("Glyph char metrics missing") } @@ -396,7 +396,7 @@ func (p *StyledParagraph) wrapText() error { if lineWidth+w > p.wrapWidth*1000.0 { // Goes out of bounds: Wrap. // Breaks on the character. - // XXX/TODO: when goes outside: back up to next space, + // TODO: when goes outside: back up to next space, // otherwise break on the character. idx := -1 for j := len(glyphs) - 1; j >= 0; j-- { @@ -479,7 +479,7 @@ func (p *StyledParagraph) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawCon if p.Height() > ctx.Height { // Goes out of the bounds. Write on a new template instead and create a new context at upper // left corner. - // XXX/TODO: Handle case when Paragraph is larger than the Page... + // TODO: Handle case when Paragraph is larger than the Page... // Should be fine if we just break on the paragraph, i.e. splitting it up over 2+ pages blocks = append(blocks, blk) diff --git a/pdf/creator/table.go b/pdf/creator/table.go index 238d491c..a494f883 100644 --- a/pdf/creator/table.go +++ b/pdf/creator/table.go @@ -65,7 +65,7 @@ func newTable(cols int) *Table { t.rowHeights = []float64{} // Default row height - // XXX/TODO: Base on contents instead? + // TODO: Base on contents instead? t.defaultRowHeight = 10.0 t.cells = []*TableCell{} diff --git a/pdf/extractor/text.go b/pdf/extractor/text.go index 28b18ca6..ab2c0984 100644 --- a/pdf/extractor/text.go +++ b/pdf/extractor/text.go @@ -380,7 +380,7 @@ func (to *textObject) setFont(name string, size float64) error { (*to.fontStack)[len(*to.fontStack)-1] = font } } else if err == model.ErrFontNotSupported { - // XXX: Do we need to handle this case in a special way? + // TODO: Do we need to handle this case in a special way? return err } else { return err diff --git a/pdf/internal/textencoding/glyphs_glyphlist.go b/pdf/internal/textencoding/glyphs_glyphlist.go index fdffb21d..8276f792 100644 --- a/pdf/internal/textencoding/glyphs_glyphlist.go +++ b/pdf/internal/textencoding/glyphs_glyphlist.go @@ -21,14 +21,14 @@ import ( const MissingCodeRune = '\ufffd' // � // GlyphToRune returns the rune corresponding to glyph `glyph` if there is one. -// XXX: TODO: Can we return a string here? e.g. When we are extracting text, we want to get "ffi" -// rather than 'ffi'. We only need a glyph ➞ rune map when we need to convert back to -// glyphs. -// We are currently applying RuneToString to the output of functions that call -// GlyphToRune. While this gives the same result, it makes the calling code complex and -// fragile. -// XXX: TODO: Can we combine all the tables glyphAliases, glyphlistGlyphToRuneMap, -// texGlyphlistGlyphToStringMap, additionalGlyphlistGlyphToRuneMap and ".notdef"? +// TODO: Can we return a string here? e.g. When we are extracting text, we want to get "ffi" +// rather than 'ffi'. We only need a glyph ➞ rune map when we need to convert back to +// glyphs. +// We are currently applying RuneToString to the output of functions that call +// GlyphToRune. While this gives the same result, it makes the calling code complex and +// fragile. +// TODO: Can we combine all the tables glyphAliases, glyphlistGlyphToRuneMap, +// texGlyphlistGlyphToStringMap, additionalGlyphlistGlyphToRuneMap and ".notdef"? func GlyphToRune(glyph GlyphName) (rune, bool) { // We treat glyph "eight.lf" the same as glyph "eight". // See contrib/testdata/font/Ingmar.txt diff --git a/pdf/model/font.go b/pdf/model/font.go index 94bcc938..b92a156c 100644 --- a/pdf/model/font.go +++ b/pdf/model/font.go @@ -374,7 +374,7 @@ func (font PdfFont) Encoder() textencoding.TextEncoder { t := font.actualFont() if t == nil { common.Log.Debug("ERROR: Encoder not implemented for font type=%#T", font.context) - // XXX: Should we return a default encoding? + // TODO: Should we return a default encoding? return nil } return t.Encoder() diff --git a/pdf/model/fontfile.go b/pdf/model/fontfile.go index 0a22de4c..30de1c12 100644 --- a/pdf/model/fontfile.go +++ b/pdf/model/fontfile.go @@ -68,7 +68,7 @@ func newFontFileFromPdfObject(obj core.PdfObject) (*fontFile, error) { if !ok { fontfile.subtype = subtype if subtype == "Type1C" { - // XXX: TODO Add Type1C support + // TODO: Add Type1C support common.Log.Debug("Type1C fonts are currently not supported") return nil, ErrType1CFontNotSupported } @@ -153,7 +153,7 @@ func (fontfile *fontFile) parseAsciiPart(data []byte) error { } encoder, err := textencoding.NewCustomSimpleTextEncoder(encodings, nil) if err != nil { - // XXX: Logging an error because we need to fix all these misses. + // TODO: Logging an error because we need to fix all these misses. common.Log.Error("UNKNOWN GLYPH: err=%v", err) return nil } diff --git a/pdf/model/fonts/ttfparser.go b/pdf/model/fonts/ttfparser.go index 303348ca..de1eb574 100644 --- a/pdf/model/fonts/ttfparser.go +++ b/pdf/model/fonts/ttfparser.go @@ -99,7 +99,7 @@ type TtfType struct { } // MakeToUnicode returns a ToUnicode CMap based on the encoding of `ttf`. -// XXX(peterwilliams97): This currently gives a bad text mapping for creator_test.go but leads to an +// TODO(peterwilliams97): This currently gives a bad text mapping for creator_test.go but leads to an // otherwise valid PDF file that Adobe Reader displays without error. func (ttf *TtfType) MakeToUnicode() *cmap.CMap { codeToUnicode := make(map[cmap.CharCode]rune) @@ -504,7 +504,7 @@ func (t *ttfParser) parseCmapVersion(offset int64) error { return t.parseCmapFormat12() default: common.Log.Debug("ERROR: Unsupported cmap format=%d", format) - return nil // XXX(peterwilliams97): Can't return an error here if creator_test.go is to pass. + return nil // TODO(peterwilliams97): Can't return an error here if creator_test.go is to pass. } } diff --git a/pdf/model/functions_test.go b/pdf/model/functions_test.go index 73b4a60c..f636674d 100644 --- a/pdf/model/functions_test.go +++ b/pdf/model/functions_test.go @@ -1,5 +1,5 @@ // Test functions -// XXX: We need tests of type 0, type 2, type 3, type 4 functions. Particularly type 0 is complex and +// TODO: We need tests of type 0, type 2, type 3, type 4 functions. Particularly type 0 is complex and // needs comprehensive tests. package model @@ -23,7 +23,7 @@ type Type4TestCase struct { Expected []float64 } -// TODO/XXX: Implement example 2 from page 167. +// TODO: Implement example 2 from page 167. func TestType4Function1(t *testing.T) { rawText := ` diff --git a/pdf/model/image.go b/pdf/model/image.go index 0d5ba0ed..fdc638aa 100644 --- a/pdf/model/image.go +++ b/pdf/model/image.go @@ -150,7 +150,7 @@ func (img *Image) ToGoImage() (goimage.Image, error) { } else if img.ColorComponents == 4 { imgout = goimage.NewCMYK(bounds) } else { - // XXX? Force RGB convert? + // TODO: Force RGB convert? common.Log.Debug("Unsupported number of colors components per sample: %d", img.ColorComponents) return nil, errors.New("Unsupported colors") } diff --git a/pdf/model/outlines.go b/pdf/model/outlines.go index 0deb28cb..95ac108c 100644 --- a/pdf/model/outlines.go +++ b/pdf/model/outlines.go @@ -182,7 +182,7 @@ func (this *PdfReader) newPdfOutlineItemFromIndirectObject(container *PdfIndirec } } if obj := dict.Get("SE"); obj != nil { - // XXX: To add structure element support. + // TODO: To add structure element support. // Currently not supporting structure elements. item.SE = nil /* @@ -270,7 +270,7 @@ func (this *PdfOutlineItem) ToPdfObject() PdfObject { dict.Set("A", this.A) } if obj := dict.Get("SE"); obj != nil { - // XXX: Currently not supporting structure element hierarchy. + // TODO: Currently not supporting structure element hierarchy. // Remove it. dict.Remove("SE") // delete(*dict, "SE") diff --git a/pdf/model/page.go b/pdf/model/page.go index d73526bb..bbcee163 100644 --- a/pdf/model/page.go +++ b/pdf/model/page.go @@ -90,7 +90,7 @@ func (this *PdfPage) Duplicate() *PdfPage { // Note that a new container is created (indirect object). func (reader *PdfReader) newPdfPageFromDict(p *PdfObjectDictionary) (*PdfPage, error) { page := NewPdfPage() - page.pageDict = p //XXX? + page.pageDict = p // TODO d := *p diff --git a/pdf/model/reader.go b/pdf/model/reader.go index 008ac12a..ba87bfe4 100755 --- a/pdf/model/reader.go +++ b/pdf/model/reader.go @@ -695,7 +695,7 @@ func (this *PdfReader) GetPageAsIndirectObject(pageNumber int) (PdfObject, error page := this.pageList[pageNumber-1] // Look up all references related to page and load everything. - // XXX/TODO: Use of traverse object data will be limited when lazy-loading is supported. + // TODO: Use of traverse object data will be limited when lazy-loading is supported. err := this.traverseObjectData(page) if err != nil { return nil, err diff --git a/pdf/model/signature.go b/pdf/model/signature.go index 35afc4fb..55972db5 100644 --- a/pdf/model/signature.go +++ b/pdf/model/signature.go @@ -91,7 +91,7 @@ func (sig *PdfSignature) ToPdfObject() core.PdfObject { dict.Set("ContactInfo", sig.ContactInfo) } - // XXX/FIXME: ByteRange and Contents need to be updated dynamically. + // FIXME: ByteRange and Contents need to be updated dynamically. return container } diff --git a/pdf/model/writer.go b/pdf/model/writer.go index 7ff19b5e..3c9be2ee 100644 --- a/pdf/model/writer.go +++ b/pdf/model/writer.go @@ -574,7 +574,7 @@ func (this *PdfWriter) writeObject(num int, obj PdfObject) { return } - // XXX/TODO: Add a default encoder if Filter not specified? + // TODO: Add a default encoder if Filter not specified? // Still need to make sure is encrypted. if pobj, isStream := obj.(*PdfObjectStream); isStream { this.crossReferenceMap[num] = crossReference{Type: 1, Offset: this.writePos, Generation: pobj.GenerationNumber} diff --git a/pdf/ps/parser.go b/pdf/ps/parser.go index afbf1e46..e865c8ab 100644 --- a/pdf/ps/parser.go +++ b/pdf/ps/parser.go @@ -175,7 +175,7 @@ func (p *PSParser) parseNumber() (PSObject, error) { isFloat = true } else if bb[0] == 'e' { // Exponential number format. - // XXX Is this supported in PS? + // TODO: Is this supported in PS? b, _ := p.reader.ReadByte() numStr += string(b) isFloat = true