def add_cell_styles(self, c, begin, end, mode="td"): def getColor(a, b): return a self.mode = mode.upper() if c.frag.backColor and mode != "tr": # XXX Stimmt das so? self.add_style(('BACKGROUND', begin, end, c.frag.backColor)) if 0: log.debug("%r", ( begin, end, c.frag.borderTopWidth, c.frag.borderTopStyle, c.frag.borderTopColor, c.frag.borderBottomWidth, c.frag.borderBottomStyle, c.frag.borderBottomColor, c.frag.borderLeftWidth, c.frag.borderLeftStyle, c.frag.borderLeftColor, c.frag.borderRightWidth, c.frag.borderRightStyle, c.frag.borderRightColor, )) if getBorderStyle( c.frag.borderTopStyle ) and c.frag.borderTopWidth and c.frag.borderTopColor is not None: self.add_style( ('LINEABOVE', begin, (end[0], begin[1]), c.frag.borderTopWidth, c.frag.borderTopColor, "squared")) if getBorderStyle( c.frag.borderLeftStyle ) and c.frag.borderLeftWidth and c.frag.borderLeftColor is not None: self.add_style( ('LINEBEFORE', begin, (begin[0], end[1]), c.frag.borderLeftWidth, c.frag.borderLeftColor, "squared")) if getBorderStyle( c.frag.borderRightStyle ) and c.frag.borderRightWidth and c.frag.borderRightColor is not None: self.add_style( ('LINEAFTER', (end[0], begin[1]), end, c.frag.borderRightWidth, c.frag.borderRightColor, "squared")) if getBorderStyle( c.frag.borderBottomStyle ) and c.frag.borderBottomWidth and c.frag.borderBottomColor is not None: self.add_style(('LINEBELOW', (begin[0], end[1]), end, c.frag.borderBottomWidth, c.frag.borderBottomColor, "squared")) self.add_style(('LEFTPADDING', begin, end, c.frag.paddingLeft or self.padding)) self.add_style(('RIGHTPADDING', begin, end, c.frag.paddingRight or self.padding)) self.add_style(('TOPPADDING', begin, end, c.frag.paddingTop or self.padding)) self.add_style(('BOTTOMPADDING', begin, end, c.frag.paddingBottom or self.padding))
def add_cell_styles(self, c, begin, end, mode="td"): self.mode = mode.upper() if c.frag.backColor and mode != "tr": # XXX Stimmt das so? self.add_style(('BACKGROUND', begin, end, c.frag.backColor)) if 0: log.debug("%r", ( begin, end, c.frag.borderTopWidth, c.frag.borderTopStyle, c.frag.borderTopColor, c.frag.borderBottomWidth, c.frag.borderBottomStyle, c.frag.borderBottomColor, c.frag.borderLeftWidth, c.frag.borderLeftStyle, c.frag.borderLeftColor, c.frag.borderRightWidth, c.frag.borderRightStyle, c.frag.borderRightColor, )) if getBorderStyle(c.frag.borderTopStyle) and c.frag.borderTopWidth and c.frag.borderTopColor is not None: self.add_style(('LINEABOVE', begin, (end[0], begin[1]), c.frag.borderTopWidth, c.frag.borderTopColor, "squared")) if getBorderStyle(c.frag.borderLeftStyle) and c.frag.borderLeftWidth and c.frag.borderLeftColor is not None: self.add_style(('LINEBEFORE', begin, (begin[0], end[1]), c.frag.borderLeftWidth, c.frag.borderLeftColor, "squared")) if getBorderStyle(c.frag.borderRightStyle) and c.frag.borderRightWidth and c.frag.borderRightColor is not None: self.add_style(('LINEAFTER', (end[0], begin[1]), end, c.frag.borderRightWidth, c.frag.borderRightColor, "squared")) if getBorderStyle( c.frag.borderBottomStyle) and c.frag.borderBottomWidth and c.frag.borderBottomColor is not None: self.add_style(('LINEBELOW', (begin[0], end[1]), end, c.frag.borderBottomWidth, c.frag.borderBottomColor, "squared")) self.add_style( ('LEFTPADDING', begin, end, c.frag.paddingLeft or self.padding)) self.add_style( ('RIGHTPADDING', begin, end, c.frag.paddingRight or self.padding)) self.add_style( ('TOPPADDING', begin, end, c.frag.paddingTop or self.padding)) self.add_style( ('BOTTOMPADDING', begin, end, c.frag.paddingBottom or self.padding))
def _drawBorderLine(bstyle, width, color, x1, y1, x2, y2): # We need width and border style to be able to draw a border if width and getBorderStyle(bstyle): # If no color for border is given, the text color is used (like defined by W3C) if color is None: color = style.textColor # print "Border", bstyle, width, color if color is not None: canvas.setStrokeColor(color) canvas.setLineWidth(width) canvas.line(x1, y1, x2, y2)
def _drawBorderLine(bstyle, width, color, x1, y1, x2, y2): # We need width and border style to be able to draw a border if width and getBorderStyle(bstyle): # If no color for border is given, the text color is used (like defined by W3C) if color is None or color is False: #SBGrid Fix, unsure why the false makes it this far but this resolves the issue color = style.textColor # print "Border", bstyle, width, color if color is not None: canvas.setStrokeColor(color) canvas.setLineWidth(width) canvas.line(x1, y1, x2, y2)
def test_will_return_default_if_passed_value_is_non_case_sensitive_hidden( self): style = getBorderStyle("hidDen", default="defaultPassedArg") self.assertEqual(style, "defaultPassedArg")
def test_will_return_default_if_passed_value_is_non_case_sensitive_none( self): style = getBorderStyle("None", default="blah") self.assertEqual(style, "blah")
def test_will_return_value_if_passed_value_is_not_none_or_hidden(self): style = getBorderStyle("foo", default="blah") self.assertEqual(style, "foo")
def test_will_return_default_if_passed_value_is_non_case_sensitive_hidden(self): style = getBorderStyle("hidDen", default="defaultPassedArg") self.assertEqual(style, "defaultPassedArg")
def test_will_return_default_if_passed_value_is_non_case_sensitive_none(self): style = getBorderStyle("None", default="blah") self.assertEqual(style, "blah")