src/reportlab/platypus/tables.py
changeset 3038 04d53e2083bd
parent 3031 6f90e7668adb
child 3151 be7033a8ccf9
equal deleted inserted replaced
3037:e014e27ec331 3038:04d53e2083bd
   476         fontName = s.fontname
   476         fontName = s.fontname
   477         fontSize = s.fontsize
   477         fontSize = s.fontsize
   478         return max([stringWidth(x,fontName,fontSize) for x in v])
   478         return max([stringWidth(x,fontName,fontSize) for x in v])
   479 
   479 
   480     def _calc_height(self, availHeight, availWidth, H=None, W=None):
   480     def _calc_height(self, availHeight, availWidth, H=None, W=None):
   481 
       
   482         H = self._argH
   481         H = self._argH
   483         if not W: W = _calc_pc(self._argW,availWidth)   #widths array
   482         if not W: W = _calc_pc(self._argW,availWidth)   #widths array
   484 
   483 
   485         hmax = lim = len(H)
   484         hmax = lim = len(H)
   486         longTable = getattr(self,'_longTableOptimize',rl_config.longTableOptimize)
   485         longTable = getattr(self,'_longTableOptimize',rl_config.longTableOptimize)
   503             self._rowHeights = H
   502             self._rowHeights = H
   504             spanCons = {}
   503             spanCons = {}
   505             FUZZ = rl_config._FUZZ
   504             FUZZ = rl_config._FUZZ
   506             while None in H:
   505             while None in H:
   507                 i = H.index(None)
   506                 i = H.index(None)
   508                 if longTable:
       
   509                     hmax = i
       
   510                     height = reduce(operator.add, H[:i], 0)
       
   511                     # we can stop if we have filled up all available room
       
   512                     if height > availHeight: break
       
   513                 V = self._cellvalues[i] # values for row i
   507                 V = self._cellvalues[i] # values for row i
   514                 S = self._cellStyles[i] # styles for row i
   508                 S = self._cellStyles[i] # styles for row i
   515                 h = 0
   509                 h = 0
   516                 j = 0
   510                 j = 0
   517                 for j,(v, s, w) in enumerate(map(None, V, S, W)): # value, style, width (lengths must match)
   511                 for j,(v, s, w) in enumerate(map(None, V, S, W)): # value, style, width (lengths must match)
   545                                 x = r0,r1
   539                                 x = r0,r1
   546                                 spanCons[x] = max(spanCons.get(x,t),t)
   540                                 spanCons[x] = max(spanCons.get(x,t),t)
   547                                 t = 0
   541                                 t = 0
   548                     if t>h: h = t   #record a new maximum
   542                     if t>h: h = t   #record a new maximum
   549                 H[i] = h
   543                 H[i] = h
       
   544                 # we can stop if we have filled up all available room
       
   545                 if longTable:
       
   546                     hmax = i
       
   547                     height = reduce(operator.add, H[:i], 0)
       
   548                     if height > availHeight:
       
   549                         break
   550             if None not in H: hmax = lim
   550             if None not in H: hmax = lim
   551 
   551 
   552             if spanCons:
   552             if spanCons:
   553                 spanFixDim(H0,H,spanCons)
   553                 spanFixDim(H0,H,spanCons)
   554 
   554