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): 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 test_copy_attrs(self): a = self.A() b = self.B(19, 22) copy_attrs(a, b, ["attr", "attr1"]) self.assertEqual(a.attr, 19) self.assertEqual(a.attr1, 22)
def test_copy_attrs(self): a = self.A() b = self.B(19, 22) copy_attrs(a, b, ["attr", "attr1"]) self.assertEqual(a.attr, 19) self.assertEqual(a.attr1, 22)