src/reportlab/platypus/tables.py
branchpy33
changeset 3723 99aa837b6703
parent 3721 0c93dd8ff567
child 3781 df8b57380768
equal deleted inserted replaced
3722:29c11b905751 3723:99aa837b6703
   576                     hmax = i
   576                     hmax = i
   577                     height = sum(H[:i])
   577                     height = sum(H[:i])
   578                     if height > availHeight:
   578                     if height > availHeight:
   579                         #we can terminate if all spans are complete in H[:i]
   579                         #we can terminate if all spans are complete in H[:i]
   580                         if spanCons:
   580                         if spanCons:
   581                             msr = max([x[1] for x in list(spanCons.keys())])  #RS=[endrowspan,.....]
   581                             msr = max([x[1] for x in spanCons.keys()])  #RS=[endrowspan,.....]
   582                             if hmax>=msr:
   582                             if hmax>=msr:
   583                                 break
   583                                 break
   584             if None not in H: hmax = lim
   584             if None not in H: hmax = lim
   585 
   585 
   586             if spanCons:
   586             if spanCons:
   759             # space.  A column may not shrink less than its minimum width,
   759             # space.  A column may not shrink less than its minimum width,
   760             # however, which makes this a bit more complicated.
   760             # however, which makes this a bit more complicated.
   761             desiredWidths = []
   761             desiredWidths = []
   762             totalDesired = 0
   762             totalDesired = 0
   763             effectiveRemaining = remaining
   763             effectiveRemaining = remaining
   764             for colNo, minimum in list(minimums.items()):
   764             for colNo, minimum in minimums.items():
   765                 w = W[colNo]
   765                 w = W[colNo]
   766                 if _endswith(w,'%'):
   766                 if _endswith(w,'%'):
   767                     desired = (float(w[:-1])/percentTotal)*availWidth
   767                     desired = (float(w[:-1])/percentTotal)*availWidth
   768                 elif w == '*':
   768                 elif w == '*':
   769                     desired = defaultDesired
   769                     desired = defaultDesired
   819                 for minimum, desired, colNo in finalSet:
   819                 for minimum, desired, colNo in finalSet:
   820                     adjusted = proportion * desired
   820                     adjusted = proportion * desired
   821                     assert adjusted >= minimum
   821                     assert adjusted >= minimum
   822                     W[colNo] = adjusted
   822                     W[colNo] = adjusted
   823         else:
   823         else:
   824             for colNo, minimum in list(minimums.items()):
   824             for colNo, minimum in minimums.items():
   825                 W[colNo] = minimum
   825                 W[colNo] = minimum
   826         if verbose: print('new widths are:', W)
   826         if verbose: print('new widths are:', W)
   827         self._argW = self._colWidths = W
   827         self._argW = self._colWidths = W
   828         return W
   828         return W
   829 
   829 
   984                 width = colpositions[col1+1] - x
   984                 width = colpositions[col1+1] - x
   985                 height = rowpositions[row0] - y
   985                 height = rowpositions[row0] - y
   986                 spanRects[coord] = (x, y, width, height)
   986                 spanRects[coord] = (x, y, width, height)
   987 
   987 
   988         for _ in hBlocks, vBlocks:
   988         for _ in hBlocks, vBlocks:
   989             for value in list(_.values()):
   989             for value in _.values():
   990                 value.sort()
   990                 value.sort()
   991         self._spanRects = spanRects
   991         self._spanRects = spanRects
   992         self._vBlocks = vBlocks
   992         self._vBlocks = vBlocks
   993         self._hBlocks = hBlocks
   993         self._hBlocks = hBlocks
   994         self._hmax_spanRects = hmax
   994         self._hmax_spanRects = hmax
   996     def setStyle(self, tblstyle):
   996     def setStyle(self, tblstyle):
   997         if not isinstance(tblstyle,TableStyle):
   997         if not isinstance(tblstyle,TableStyle):
   998             tblstyle = TableStyle(tblstyle)
   998             tblstyle = TableStyle(tblstyle)
   999         for cmd in tblstyle.getCommands():
   999         for cmd in tblstyle.getCommands():
  1000             self._addCommand(cmd)
  1000             self._addCommand(cmd)
  1001         for k,v in list(tblstyle._opts.items()):
  1001         for k,v in tblstyle._opts.items():
  1002             setattr(self,k,v)
  1002             setattr(self,k,v)
  1003         for a in ('spaceBefore','spaceAfter'):
  1003         for a in ('spaceBefore','spaceAfter'):
  1004             if not hasattr(self,a) and hasattr(tblstyle,a):
  1004             if not hasattr(self,a) and hasattr(tblstyle,a):
  1005                 setattr(self,a,getattr(tblstyle,a))
  1005                 setattr(self,a,getattr(tblstyle,a))
  1006 
  1006