def toParagraphStyle(self, first): style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext) style.fontName = first.fontName style.fontSize = first.fontSize style.letterSpacing = first.letterSpacing style.leading = max(first.leading + first.leadingSpace, first.fontSize * 1.25) style.backColor = first.backColor style.spaceBefore = first.spaceBefore style.spaceAfter = first.spaceAfter style.leftIndent = first.leftIndent style.rightIndent = first.rightIndent style.firstLineIndent = first.firstLineIndent style.textColor = first.textColor style.alignment = first.alignment style.bulletFontName = first.bulletFontName or first.fontName style.bulletFontSize = first.fontSize style.bulletIndent = first.bulletIndent style.wordWrap = first.wordWrap # Border handling for Paragraph # Transfer the styles for each side of the border, *not* the whole # border values that reportlab supports. We'll draw them ourselves in # PmlParagraph. style.borderTopStyle = first.borderTopStyle style.borderTopWidth = first.borderTopWidth style.borderTopColor = first.borderTopColor style.borderBottomStyle = first.borderBottomStyle style.borderBottomWidth = first.borderBottomWidth style.borderBottomColor = first.borderBottomColor style.borderLeftStyle = first.borderLeftStyle style.borderLeftWidth = first.borderLeftWidth style.borderLeftColor = first.borderLeftColor style.borderRightStyle = first.borderRightStyle style.borderRightWidth = first.borderRightWidth style.borderRightColor = first.borderRightColor # If no border color is given, the text color is used (XXX Tables!) if (style.borderTopColor is None) and style.borderTopWidth: style.borderTopColor = first.textColor if (style.borderBottomColor is None) and style.borderBottomWidth: style.borderBottomColor = first.textColor if (style.borderLeftColor is None) and style.borderLeftWidth: style.borderLeftColor = first.textColor if (style.borderRightColor is None) and style.borderRightWidth: style.borderRightColor = first.textColor style.borderPadding = first.borderPadding style.paddingTop = first.paddingTop style.paddingBottom = first.paddingBottom style.paddingLeft = first.paddingLeft style.paddingRight = first.paddingRight style.fontName = tt2ps(first.fontName, first.bold, first.italic) return style
def toParagraphStyle(self, first): style = ParagraphStyle( 'default%d' % self.UID(), keepWithNext=first.keepWithNext) copy_attrs(style, first, ('fontName', 'fontSize', 'letterSpacing', 'backColor', 'spaceBefore', 'spaceAfter', 'leftIndent', 'rightIndent', 'firstLineIndent', 'textColor', 'alignment', 'bulletIndent', 'wordWrap', 'borderTopStyle', 'borderTopWidth', 'borderTopColor', 'borderBottomStyle', 'borderBottomWidth', 'borderBottomColor', 'borderLeftStyle', 'borderLeftWidth', 'borderLeftColor', 'borderRightStyle', 'borderRightWidth', 'borderRightColor', 'paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight', 'borderPadding' ) ) style.leading = max( first.leading + first.leadingSpace, first.fontSize * 1.25) style.bulletFontName = first.bulletFontName or first.fontName style.bulletFontSize = first.fontSize # Border handling for Paragraph # Transfer the styles for each side of the border, *not* the whole # border values that reportlab supports. We'll draw them ourselves in # PmlParagraph. # If no border color is given, the text color is used (XXX Tables!) if (style.borderTopColor is None) and style.borderTopWidth: style.borderTopColor = first.textColor if (style.borderBottomColor is None) and style.borderBottomWidth: style.borderBottomColor = first.textColor if (style.borderLeftColor is None) and style.borderLeftWidth: style.borderLeftColor = first.textColor if (style.borderRightColor is None) and style.borderRightWidth: style.borderRightColor = first.textColor style.fontName = tt2ps(first.fontName, first.bold, first.italic) return style
def toParagraphStyle(self, first, full=False): style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext) style.fontName = first.fontName style.fontSize = first.fontSize style.leading = max(first.leading, first.fontSize * 1.25) style.backColor = first.backColor style.spaceBefore = first.spaceBefore style.spaceAfter = first.spaceAfter style.leftIndent = first.leftIndent style.rightIndent = first.rightIndent style.firstLineIndent = first.firstLineIndent style.textColor = first.textColor style.alignment = first.alignment style.bulletFontName = first.bulletFontName or first.fontName style.bulletFontSize = first.fontSize style.bulletIndent = first.bulletIndent # Border handling for Paragraph # Transfer the styles for each side of the border, *not* the whole # border values that reportlab supports. We'll draw them ourselves in # PmlParagraph. style.borderTopStyle = first.borderTopStyle style.borderTopWidth = first.borderTopWidth style.borderTopColor = first.borderTopColor style.borderBottomStyle = first.borderBottomStyle style.borderBottomWidth = first.borderBottomWidth style.borderBottomColor = first.borderBottomColor style.borderLeftStyle = first.borderLeftStyle style.borderLeftWidth = first.borderLeftWidth style.borderLeftColor = first.borderLeftColor style.borderRightStyle = first.borderRightStyle style.borderRightWidth = first.borderRightWidth style.borderRightColor = first.borderRightColor # If no border color is given, the text color is used (XXX Tables!) if (style.borderTopColor is None) and style.borderTopWidth: style.borderTopColor = first.textColor if (style.borderBottomColor is None) and style.borderBottomWidth: style.borderBottomColor = first.textColor if (style.borderLeftColor is None) and style.borderLeftWidth: style.borderLeftColor = first.textColor if (style.borderRightColor is None) and style.borderRightWidth: style.borderRightColor = first.textColor style.borderPadding = first.borderPadding style.paddingTop = first.paddingTop style.paddingBottom = first.paddingBottom style.paddingLeft = first.paddingLeft style.paddingRight = first.paddingRight # This is the old code replaced by the above, kept for reference #style.borderWidth = 0 #if getBorderStyle(first.borderTopStyle): # style.borderWidth = max(first.borderLeftWidth, first.borderRightWidth, first.borderTopWidth, first.borderBottomWidth) # style.borderPadding = first.borderPadding # + first.borderWidth # style.borderColor = first.borderTopColor # # If no border color is given, the text color is used (XXX Tables!) # if (style.borderColor is None) and style.borderWidth: # style.borderColor = first.textColor if full: style.fontName = tt2ps(first.fontName, first.bold, first.italic) return style