Beispiel #1
0
def clone(self, **kwargs):
    n = ParaFrag(**self.__dict__)
    if kwargs:
        d = n.__dict__
        d.update(kwargs)
        # This else could cause trouble in Paragraphs with images etc.
        if "cbDefn" in d:
            del d["cbDefn"]
    n.bulletText = None
    return n
Beispiel #2
0
def clone(self, **kwargs):
    n = ParaFrag(**self.__dict__)
    if kwargs:
        d = n.__dict__
        d.update(kwargs)
        # This else could cause trouble in Paragraphs with images etc.
        if "cbDefn" in d:
            del d["cbDefn"]
    n.bulletText = None
    return n
Beispiel #3
0
 def setUp(self):
     style = ParaFrag()
     style.fontName = 'Times-Roman'
     style.fontSize = 12
     style.textColor = black
     style.bulletFontName = black
     style.bulletFontName = 'Times-Roman'
     style.bulletFontSize = 12
     style.bulletOffsetY = 3
     style.textTransform = None
     self.style = style
Beispiel #4
0
 def setUp(self):
     style=ParaFrag()
     style.fontName='Times-Roman'
     style.fontSize = 12
     style.textColor = black
     style.bulletFontName = black
     style.bulletFontName='Times-Roman'
     style.bulletFontSize=12
     self.style = style        
 def setUp(self):
     style=ParaFrag()
     style.fontName='Times-Roman'
     style.fontSize = 12
     style.textColor = black
     style.bulletFontName = black
     style.bulletFontName='Times-Roman'
     style.bulletFontSize=12
     style.bulletOffsetY=3
     self.style = style        
 def setUp(self):
     style = ParaFrag()
     style.fontName = "Times-Roman"
     style.fontSize = 12
     style.textColor = black
     style.bulletFontName = black
     style.bulletFontName = "Times-Roman"
     style.bulletFontSize = 12
     style.bulletOffsetY = 3
     style.textTransform = None
     self.style = style
Beispiel #7
0
def getParaFrag(style):
    frag = ParaFrag()
    frag.sub = 0
    frag.super = 0
    frag.rise = 0
    frag.underline = 0  # XXX Need to be able to set color to fit CSS tests
    frag.strike = 0
    frag.greek = 0
    frag.link = None
    frag.text = ""
    frag.fontName = "Times-Roman"
    frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
    frag.fontSize = style.fontSize
    frag.textColor = style.textColor

    # Extras
    frag.leading = 0
    frag.letterSpacing = "normal"
    frag.leadingSource = "150%"
    frag.leadingSpace = 0
    frag.backColor = None
    frag.spaceBefore = 0
    frag.spaceAfter = 0
    frag.leftIndent = 0
    frag.rightIndent = 0
    frag.firstLineIndent = 0
    frag.keepWithNext = False
    frag.alignment = TA_LEFT
    frag.vAlign = None

    frag.borderWidth = 1
    frag.borderStyle = None
    frag.borderPadding = 0
    frag.borderColor = None

    frag.borderLeftWidth = frag.borderWidth
    frag.borderLeftColor = frag.borderColor
    frag.borderLeftStyle = frag.borderStyle
    frag.borderRightWidth = frag.borderWidth
    frag.borderRightColor = frag.borderColor
    frag.borderRightStyle = frag.borderStyle
    frag.borderTopWidth = frag.borderWidth
    frag.borderTopColor = frag.borderColor
    frag.borderTopStyle = frag.borderStyle
    frag.borderBottomWidth = frag.borderWidth
    frag.borderBottomColor = frag.borderColor
    frag.borderBottomStyle = frag.borderStyle

    frag.paddingLeft = 0
    frag.paddingRight = 0
    frag.paddingTop = 0
    frag.paddingBottom = 0

    frag.listStyleType = None
    frag.listStyleImage = None
    frag.whiteSpace = "normal"

    frag.wordWrap = None

    frag.pageNumber = False
    frag.pageCount = False
    frag.height = None
    frag.width = None

    frag.bulletIndent = 0
    frag.bulletText = None
    frag.bulletFontName = "Helvetica"

    frag.zoom = 1.0

    frag.outline = False
    frag.outlineLevel = 0
    frag.outlineOpen = False

    frag.insideStaticFrame = 0

    return frag
Beispiel #8
0
def getParaFrag(style):
    frag = ParaFrag()
    frag.sub = 0
    frag.super = 0
    frag.rise = 0
    frag.underline = 0  # XXX Need to be able to set color to fit CSS tests
    frag.strike = 0
    frag.greek = 0
    frag.link = None
    frag.text = ""
    frag.fontName = "Times-Roman"
    frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
    frag.fontSize = style.fontSize
    frag.textColor = style.textColor

    # Extras
    frag.leading = 0
    frag.letterSpacing = "normal"
    frag.leadingSource = "150%"
    frag.leadingSpace = 0
    frag.backColor = None
    frag.spaceBefore = 0
    frag.spaceAfter = 0
    frag.leftIndent = 0
    frag.rightIndent = 0
    frag.firstLineIndent = 0
    frag.keepWithNext = False
    frag.alignment = TA_LEFT
    frag.vAlign = None

    frag.borderWidth = 1
    frag.borderStyle = None
    frag.borderPadding = 0
    frag.borderColor = None

    frag.borderLeftWidth = frag.borderWidth
    frag.borderLeftColor = frag.borderColor
    frag.borderLeftStyle = frag.borderStyle
    frag.borderRightWidth = frag.borderWidth
    frag.borderRightColor = frag.borderColor
    frag.borderRightStyle = frag.borderStyle
    frag.borderTopWidth = frag.borderWidth
    frag.borderTopColor = frag.borderColor
    frag.borderTopStyle = frag.borderStyle
    frag.borderBottomWidth = frag.borderWidth
    frag.borderBottomColor = frag.borderColor
    frag.borderBottomStyle = frag.borderStyle

    frag.paddingLeft = 0
    frag.paddingRight = 0
    frag.paddingTop = 0
    frag.paddingBottom = 0

    frag.listStyleType = None
    frag.listStyleImage = None
    frag.whiteSpace = "normal"

    frag.wordWrap = None

    frag.pageNumber = False
    frag.pageCount = False
    frag.height = None
    frag.width = None

    frag.bulletIndent = 0
    frag.bulletText = None
    frag.bulletFontName = "Helvetica"

    frag.zoom = 1.0

    frag.outline = False
    frag.outlineLevel = 0
    frag.outlineOpen = False

    frag.insideStaticFrame = 0

    return frag
Beispiel #9
0
def clone(self, **kwargs):
    n = ParaFrag(**self.__dict__)
    if kwargs:
        n.__dict__.update(kwargs)
    return n
Beispiel #10
0
def getParaFrag(style):
    frag = ParaFrag()

    set_value(frag,
              ('sub', 'super', 'rise', 'underline', 'strike', 'greek',
               'leading', 'leadingSpace', 'spaceBefore', 'spaceAfter',
               'leftIndent', 'rightIndent', 'firstLineIndent', 'borderPadding',
               'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom',
               'bulletIndent', 'insideStaticFrame', 'outlineLevel'), 0)

    set_value(frag, ('backColor', 'vAlign', 'link', 'borderStyle',
                     'borderColor', 'listStyleType', 'listStyleImage',
                     'wordWrap', 'height', 'width', 'bulletText'), None)
    set_value(
        frag,
        ('pageNumber', 'pageCount', 'outline', 'outlineOpen', 'keepWithNext'),
        False)

    frag.text = ""
    frag.fontName = "Times-Roman"
    frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
    frag.fontSize = style.fontSize
    frag.textColor = style.textColor

    # Extras
    frag.letterSpacing = "normal"
    frag.leadingSource = "150%"
    frag.alignment = TA_LEFT
    frag.borderWidth = 1

    frag.borderLeftWidth = frag.borderWidth
    frag.borderLeftColor = frag.borderColor
    frag.borderLeftStyle = frag.borderStyle
    frag.borderRightWidth = frag.borderWidth
    frag.borderRightColor = frag.borderColor
    frag.borderRightStyle = frag.borderStyle
    frag.borderTopWidth = frag.borderWidth
    frag.borderTopColor = frag.borderColor
    frag.borderTopStyle = frag.borderStyle
    frag.borderBottomWidth = frag.borderWidth
    frag.borderBottomColor = frag.borderColor
    frag.borderBottomStyle = frag.borderStyle

    frag.whiteSpace = "normal"
    frag.bulletFontName = "Helvetica"
    frag.zoom = 1.0

    return frag
Beispiel #11
0
    def elem2frags(self, elem, style):
        #print "elem2frags(%s)" % elem
        frag = ParaFrag()
        frag.text = ''
        frag.fontName = style.fontName
        frag.fontSize = style.fontSize
        frag.textColor = style.textColor
        frag.rise = style.rise
        frag.underline = style.underline
        frag.strike = 0  # added for reportlab 2.0
        frag.link = None  # added for reportlab 2.0
        if elem.__class__ == html.CDATA:
            frag.text = " ".join(elem.text.split())
            if elem.text.startswith(" "):
                frag.text = " " + frag.text
            if elem.text.endswith(" "):
                frag.text += " "

            #frag.text=elem.text
            yield frag
            return
        if elem.__class__ == html.BR:
            #frag.text='\n'
            frag.lineBreak = True
            yield frag
            return
        assert hasattr(elem, 'content')
        if elem.__class__ in (html.EM, html.I):
            family, bold, italic = ps2tt(frag.fontName)
            frag.fontName = tt2ps(family, bold, 1)
            #frag.fontName=frag.fontName+"-Italic"
        elif elem.__class__ == html.TT:
            family, bold, italic = ps2tt(frag.fontName)
            frag.fontName = tt2ps("Courier", bold, italic)
        elif elem.__class__ == html.B:
            family, bold, italic = ps2tt(frag.fontName)
            frag.fontName = tt2ps(family, 1, italic)
        elif elem.__class__ == html.U:
            frag.underline = True
        elif elem.__class__ == html.SUP:
            frag.rise = True
        else:
            raise "Cannot handle <%s> inside a paragraph" \
                  % elem.tag()
##         for e in elem.content:
##             if e.__class__ == html.CDATA:
##                 frag.text += e.text
##             else:
##                 for ee in elem.content:
##                     for f in self.elem2frags(ee,frag):
##                         yield f

        for e in elem.content:
            for f in self.elem2frags(e, frag):
                yield f
        yield frag
def getParaFrag(style):
    frag = ParaFrag()
    frag.sub = 0
    frag.super = 0
    frag.rise = 0
    frag.underline = 0
    frag.strike = 0
    frag.greek = 0
    frag.link = None
    frag.text = ""

    # frag.lineBreak = 0
    # if bullet:
    #    frag.fontName, frag.bold, frag.italic = ps2tt(style.bulletFontName)
    #    frag.fontSize = style.bulletFontSize
    #    frag.textColor = hasattr(style,'bulletColor') and style.bulletColor or style.textColor
    # else:

    frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
    frag.fontName = "Times-Roman"
    frag.fontSize = style.fontSize
    frag.textColor = style.textColor

    # Extras
    frag.leading = 0
    frag.leadingSource = "150%"
    frag.backColor = white
    frag.borderWidth = 0
    frag.borderPadding = 0
    frag.borderColor = None
    frag.spaceBefore = 0
    frag.spaceAfter = 0
    frag.leftIndent = 0
    frag.rightIndent = 0
    frag.firstLineIndent = 0
    frag.keepWithNext = False
    frag.alignment = TA_LEFT
    frag.vAlign = None

    frag.borderLeftWidth = 0
    frag.borderLeftColor = None
    frag.borderLeftStyle = None
    frag.borderRightWidth = 0
    frag.borderRightColor = None
    frag.borderRightStyle = None
    frag.borderTopWidth = 0
    frag.borderTopColor = None
    frag.borderTopStyle = None
    frag.borderBottomWidth = 0
    frag.borderBottomColor = None
    frag.borderBottomStyle = None

    frag.paddingLeft = 0
    frag.paddingRight = 0
    frag.paddingTop = 0
    frag.paddingBottom = 0

    frag.listStyleType = None
    frag.whiteSpace = "normal"

    frag.pageNumber = False
    frag.height = None
    frag.width = None

    frag.bulletIndent = 0
    frag.bulletText = None
    frag.zoom = 1.0

    frag.outline = False
    frag.outlineLevel = 0
    frag.outlineOpen = False

    return frag
Beispiel #13
0
def getParaFrag(style):
    frag = ParaFrag()

    set_value(frag,
              ('sub', 'super', 'rise', 'underline', 'strike', 'greek',
               'leading', 'leadingSpace', 'spaceBefore',
               'spaceAfter', 'leftIndent', 'rightIndent', 'firstLineIndent',
               'borderPadding', 'paddingLeft', 'paddingRight',
               'paddingTop', 'paddingBottom', 'bulletIndent',
               'insideStaticFrame', 'outlineLevel'
               ),
              0)

    set_value(frag,
              ('backColor', 'vAlign', 'link', 'borderStyle',
               'borderColor', 'listStyleType', 'listStyleImage',
               'wordWrap', 'height', 'width', 'bulletText'
               ),
              None
              )
    set_value(frag,
              ('pageNumber', 'pageCount', 'outline',
               'outlineOpen', 'keepWithNext'),
              False)

    frag.text = ""
    frag.fontName = "Times-Roman"
    frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
    frag.fontSize = style.fontSize
    frag.textColor = style.textColor

    # Extras
    frag.letterSpacing = "normal"
    frag.leadingSource = "150%"
    frag.alignment = TA_LEFT
    frag.borderWidth = 1

    frag.borderLeftWidth = frag.borderWidth
    frag.borderLeftColor = frag.borderColor
    frag.borderLeftStyle = frag.borderStyle
    frag.borderRightWidth = frag.borderWidth
    frag.borderRightColor = frag.borderColor
    frag.borderRightStyle = frag.borderStyle
    frag.borderTopWidth = frag.borderWidth
    frag.borderTopColor = frag.borderColor
    frag.borderTopStyle = frag.borderStyle
    frag.borderBottomWidth = frag.borderWidth
    frag.borderBottomColor = frag.borderColor
    frag.borderBottomStyle = frag.borderStyle

    frag.whiteSpace = "normal"
    frag.bulletFontName = "Helvetica"
    frag.zoom = 1.0

    return frag
Beispiel #14
0
    def elem2frags(self, elem, style):
        # print "elem2frags(%s)" % elem
        frag = ParaFrag()
        frag.text = ""
        frag.fontName = style.fontName
        frag.fontSize = style.fontSize
        frag.textColor = style.textColor
        frag.rise = style.rise
        frag.underline = style.underline
        frag.strike = 0  # added for reportlab 2.0
        frag.link = None  # added for reportlab 2.0
        if elem.__class__ == html.CDATA:
            frag.text = " ".join(elem.text.split())
            if elem.text.startswith(" "):
                frag.text = " " + frag.text
            if elem.text.endswith(" "):
                frag.text += " "

            # frag.text=elem.text
            yield frag
            return
        if elem.__class__ == html.BR:
            # frag.text='\n'
            frag.lineBreak = True
            yield frag
            return
        assert hasattr(elem, "content")
        if elem.__class__ in (html.EM, html.I):
            family, bold, italic = ps2tt(frag.fontName)
            frag.fontName = tt2ps(family, bold, 1)
            # frag.fontName=frag.fontName+"-Italic"
        elif elem.__class__ == html.TT:
            family, bold, italic = ps2tt(frag.fontName)
            frag.fontName = tt2ps("Courier", bold, italic)
        elif elem.__class__ == html.B:
            family, bold, italic = ps2tt(frag.fontName)
            frag.fontName = tt2ps(family, 1, italic)
        elif elem.__class__ == html.U:
            frag.underline = True
        elif elem.__class__ == html.SUP:
            frag.rise = True
        else:
            raise "Cannot handle <%s> inside a paragraph" % elem.tag()
        ##         for e in elem.content:
        ##             if e.__class__ == html.CDATA:
        ##                 frag.text += e.text
        ##             else:
        ##                 for ee in elem.content:
        ##                     for f in self.elem2frags(ee,frag):
        ##                         yield f

        for e in elem.content:
            for f in self.elem2frags(e, frag):
                yield f
        yield frag
Beispiel #15
0
def getParaFrag(style):   
    frag = ParaFrag()
    frag.sub = 0
    frag.super = 0
    frag.rise = 0
    frag.underline = 0 # XXX Need to be able to set color to fit CSS tests
    frag.strike = 0
    frag.greek = 0
    frag.link = None
    frag.text = ""
    
    # frag.lineBreak = 0
    #if bullet:
    #    frag.fontName, frag.bold, frag.italic = ps2tt(style.bulletFontName)
    #    frag.fontSize = style.bulletFontSize
    #    frag.textColor = hasattr(style,'bulletColor') and style.bulletColor or style.textColor
    #else:

    frag.fontName = "Times-Roman"
    frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)    
    frag.fontSize = style.fontSize
    frag.textColor = style.textColor
    
    # fontName, bold, italic, fontSize, textColor
    # are all that is set on frag from a passed in style
    
    # Extras
    frag.leading = 0
    frag.leadingSource = "150%"
    frag.leadingSpace = 0
    frag.backColor = None
    frag.spaceBefore = 0
    frag.spaceAfter = 0
    frag.leftIndent = 0 
    frag.rightIndent = 0
    frag.firstLineIndent = 0
    frag.keepWithNext = False
    frag.alignment = TA_LEFT
    frag.vAlign = None
    
    frag.borderWidth = 1
    frag.borderStyle = None
    frag.borderPadding = 0
    frag.borderColor = None

    frag.borderLeftWidth = frag.borderWidth
    frag.borderLeftColor = frag.borderColor
    frag.borderLeftStyle = frag.borderStyle
    frag.borderRightWidth = frag.borderWidth
    frag.borderRightColor = frag.borderColor
    frag.borderRightStyle = frag.borderStyle
    frag.borderTopWidth = frag.borderWidth
    frag.borderTopColor = frag.borderColor
    frag.borderTopStyle = frag.borderStyle
    frag.borderBottomWidth = frag.borderWidth
    frag.borderBottomColor = frag.borderColor
    frag.borderBottomStyle = frag.borderStyle

    frag.paddingLeft = 0
    frag.paddingRight = 0
    frag.paddingTop = 0
    frag.paddingBottom = 0

    frag.listStyleType = None
    frag.listStyleImage = None
    frag.whiteSpace = "normal"
    
    frag.pageNumber = False
    frag.height = None
    frag.width = None

    frag.bulletIndent = 0
    frag.bulletText = None
    frag.bulletFontName = "Helvetica"
    
    frag.zoom = 1.0
    
    frag.outline = False
    frag.outlineLevel = 0
    frag.outlineOpen = False
    
    frag.keepInFrameMode = "shrink"
    #frag.keepInFrameMaxWidth = None
    #frag.keepInFrameMaxHeight = None
    
    frag.insideStaticFrame = 0
    
    return frag     
Beispiel #16
0
def getParaFrag(style):
    frag = ParaFrag()
    frag.sub = 0
    frag.super = 0
    frag.rise = 0
    frag.underline = 0
    frag.strike = 0
    frag.greek = 0
    frag.link = None
    frag.text = ""

    # frag.lineBreak = 0
    #if bullet:
    #    frag.fontName, frag.bold, frag.italic = ps2tt(style.bulletFontName)
    #    frag.fontSize = style.bulletFontSize
    #    frag.textColor = hasattr(style,'bulletColor') and style.bulletColor or style.textColor
    #else:

    frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
    frag.fontName = "Times-Roman"
    frag.fontSize = style.fontSize
    frag.textColor = style.textColor

    # Extras
    frag.leading = 0
    frag.leadingSource = "150%"
    frag.backColor = white
    frag.borderWidth = 0
    frag.borderPadding = 0
    frag.borderColor = None
    frag.spaceBefore = 0
    frag.spaceAfter = 0
    frag.leftIndent = 0
    frag.rightIndent = 0
    frag.firstLineIndent = 0
    frag.keepWithNext = False
    frag.alignment = TA_LEFT
    frag.vAlign = None

    frag.borderLeftWidth = 0
    frag.borderLeftColor = None
    frag.borderLeftStyle = None
    frag.borderRightWidth = 0
    frag.borderRightColor = None
    frag.borderRightStyle = None
    frag.borderTopWidth = 0
    frag.borderTopColor = None
    frag.borderTopStyle = None
    frag.borderBottomWidth = 0
    frag.borderBottomColor = None
    frag.borderBottomStyle = None

    frag.paddingLeft = 0
    frag.paddingRight = 0
    frag.paddingTop = 0
    frag.paddingBottom = 0

    frag.listStyleType = None
    frag.whiteSpace = "normal"

    frag.pageNumber = False
    frag.height = None
    frag.width = None

    frag.bulletIndent = 0
    frag.bulletText = None
    frag.zoom = 1.0

    frag.outline = False
    frag.outlineLevel = 0
    frag.outlineOpen = False

    return frag