Server IP : 85.214.239.14 / Your IP : 3.142.198.108 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/task/3/cwd/srv/modoboa/env/lib64/python3.5/site-packages/reportlab/platypus/ |
Upload File : |
__all__ = '''MultiCol'''.split() from reportlab.lib.utils import strTypes from .flowables import Flowable, _Container, _FindSplitterMixin, _listWrapOn class MultiCol(_Container,_FindSplitterMixin,Flowable): def __init__(self,contents,widths, minHeightNeeded=36, spaceBefore=None, spaceAfter=None): if len(contents)!=len(widths): raise ValueError('%r len(contents)=%d not the same as len(widths)=%d' % (self,len(contents),len(widths))) self.contents = contents self.widths = widths self.minHeightNeeded = minHeightNeeded self._spaceBefore = spaceBefore self._spaceAfter = spaceAfter self._naW = None def nWidths(self,aW): if aW==self._naW: return self._nW nW = [].append widths = self.widths s = 0.0 for i,w in enumerate(widths): if isinstance(w,strTypes): w=w.strip() pc = w.endswith('%') if pc: w=w[:-1] try: w = float(w) except: raise ValueError('%s: nWidths failed with value %r' % (self,widths[i])) if pc: w = w*0.01*aW elif not isinstance(w,(float,int)): raise ValueError('%s: nWidths failed with value %r' % (self,widths[i])) s += w nW(w) self._naW = aW s = aW / s self._nW = [w*s for w in nW.__self__] return self._nW def wrap(self,aW,aH): widths = self.nWidths(aW) w = h = 0.0 canv = self.canv h = 0 for faW,F in zip(widths,self.contents): if not F: fW = faW fH = 0 else: fW,fH = _listWrapOn(F,faW,canv) h = max(h,fH) w += fW self.width = w self.height = h return w, h def split(self,aW,aH): if aH<self.minHeightNeeded: return [] widths = self.nWidths(aW) S = [[],[]] canv = self.canv for faW,F in zip(widths,self.contents): if not F: fW = faW fH0 = 0 S0 = [] S1 = [] else: fW,fH0,S0,S1 = self._findSplit(canv,faW,aH,content=F,paraFix=False) if S0 is F: return [] #we failed to find a split S[0].append(S0) S[1].append(S1) return [ MultiCol(S[0], self.widths, minHeightNeeded=self.minHeightNeeded, spaceBefore=self._spaceBefore, spaceAfter=self._spaceAfter), MultiCol(S[1], self.widths, minHeightNeeded=self.minHeightNeeded, spaceBefore=self._spaceBefore, spaceAfter=self._spaceAfter), ] def getSpaceAfter(self): m = self._spaceAfter if m is None: m = 0 for F in self.contents: m = max(m,_Container.getSpaceAfter(self,F)) return m def getSpaceBefore(self): m = self._spaceBefore if m is None: m = 0 for F in self.contents: m = max(m,_Container.getSpaceBefore(self,F)) return m def drawOn(self, canv, x, y, _sW=0): widths = self._nW xOffs = 0 for faW,F in zip(widths,self.contents): _Container.drawOn(self, canv, x+xOffs, y, content=F, aW=faW) xOffs += faW