reportlab/platypus/tables.py
changeset 2819 0af8d3e7dfc9
parent 2814 cddd79c163c7
child 2878 a7af19b6f9fb
equal deleted inserted replaced
2818:ccff6734b82b 2819:0af8d3e7dfc9
   463                     if height > availHeight: break
   463                     if height > availHeight: break
   464                 V = self._cellvalues[i] # values for row i
   464                 V = self._cellvalues[i] # values for row i
   465                 S = self._cellStyles[i] # styles for row i
   465                 S = self._cellStyles[i] # styles for row i
   466                 h = 0
   466                 h = 0
   467                 j = 0
   467                 j = 0
   468                 for v, s, w in map(None, V, S, W): # value, style, width (lengths must match)
   468                 for j,(v, s, w) in enumerate(map(None, V, S, W)): # value, style, width (lengths must match)
   469                     ji = j,i
   469                     ji = j,i
   470                     if ji in rowSpanCells:
   470                     if ji in rowSpanCells:
   471                         t = 0.0  # don't count it, it's either occluded or unreliable
   471                         continue # don't count it, it's either occluded or unreliable
   472                     else:
   472                     else:
   473                         if isinstance(v,(tuple,list,Flowable)):
   473                         if isinstance(v,(tuple,list,Flowable)):
   474                             if isinstance(v,Flowable): v = (v,)
   474                             if isinstance(v,Flowable): v = (v,)
   475                             if w is None and not self._canGetWidth(v):
   475                             if w is None and not self._canGetWidth(v):
   476                                 raise ValueError, "Flowable %s in cell(%d,%d) can't have auto width in\n%s" % (v[0].identity(30),i,j,self.identity(30))
   476                                 raise ValueError, "Flowable %s in cell(%d,%d) can't have auto width in\n%s" % (v[0].identity(30),i,j,self.identity(30))
   477                             if canv: canv._fontname, canv._fontsize, canv._leading = s.fontname, s.fontsize, s.leading or 1.2*s.fontsize
   477                             if canv: canv._fontname, canv._fontsize, canv._leading = s.fontname, s.fontsize, s.leading or 1.2*s.fontsize
   478                             if ji in colSpanCells:
   478                             if ji in colSpanCells:
   479                                 t = spanRanges[ji]
   479                                 t = spanRanges[ji]
       
   480                                 if not t: continue
   480                                 w = max(colpositions[t[2]+1]-colpositions[t[0]],w)
   481                                 w = max(colpositions[t[2]+1]-colpositions[t[0]],w)
   481                             dW,t = self._listCellGeom(v,w or self._listValueWidth(v),s)
   482                             dW,t = self._listCellGeom(v,w or self._listValueWidth(v),s)
   482                             if canv: canv._fontname, canv._fontsize, canv._leading = saved
   483                             if canv: canv._fontname, canv._fontsize, canv._leading = saved
   483                             dW = dW + s.leftPadding + s.rightPadding
   484                             dW = dW + s.leftPadding + s.rightPadding
   484                             if not rl_config.allowTableBoundsErrors and dW>w:
   485                             if not rl_config.allowTableBoundsErrors and dW>w:
   485                                 raise "LayoutError", "Flowable %s (%sx%s points) too wide for cell(%d,%d) (%sx* points) in\n%s" % (v[0].identity(30),fp_str(dW),fp_str(t),i,j, fp_str(w), self.identity(30))
   486                                 raise "LayoutError", "Flowable %s (%sx%s points) too wide for cell(%d,%d) (%sx* points) in\n%s" % (v[0].identity(30),fp_str(dW),fp_str(t),i,j, fp_str(w), self.identity(30))
   486                         else:
   487                         else:
   487                             v = (v is not None and str(v) or '').split("\n")
   488                             v = (v is not None and str(v) or '').split("\n")
   488                             t = (s.leading or 1.2*s.fontSize)*len(v)
   489                             t = (s.leading or 1.2*s.fontSize)*len(v)
   489                         t = t+s.bottomPadding+s.topPadding
   490                         t += s.bottomPadding+s.topPadding
   490                     if t>h: h = t   #record a new maximum
   491                     if t>h: h = t   #record a new maximum
   491                     j = j + 1
       
   492                 H[i] = h
   492                 H[i] = h
   493             if None not in H: hmax = lim
   493             if None not in H: hmax = lim
   494 
   494 
   495         height = self._height = reduce(operator.add, H[:hmax], 0)
   495         height = self._height = reduce(operator.add, H[:hmax], 0)
   496         self._rowpositions = [height]    # index 0 is actually topline; we skip when processing cells
   496         self._rowpositions = [height]    # index 0 is actually topline; we skip when processing cells