mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-27 13:48:51 +08:00
don't use XXX for TODOs
This commit is contained in:
parent
6d2c39043c
commit
9f0df8945d
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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())
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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{}
|
||||
|
@ -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)
|
||||
|
@ -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{}
|
||||
|
@ -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
|
||||
|
@ -21,14 +21,14 @@ import (
|
||||
const MissingCodeRune = '\ufffd' // <20>
|
||||
|
||||
// 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
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 := `
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user