[reportlab-users] BUG+FIX: Paragraph splitting
Dirk Holtwick
dirk.holtwick at gmail.com
Thu Dec 11 06:25:41 EST 2008
Hi Robin,
nice patch ;) And yes, it works fine.
I applied it to my implementation too (see attachment).
Cheers
Dirk
Robin Becker schrieb:
> Dirk Holtwick wrote:
>> Hi,
>>
>> I found an error for paragraphs that need to split and contain inline
>> images. After a long search I found out that the reason was that
>> "autoLeading" was not inherited to the resulting split-paragraphs.
>>
>> Here is the part in Paragraph.split that needs to be modified:
>>
>> -----------------8<---------------[cut here]
>> func = self._get_split_blParaFunc()
>> P1=self.__class__(None,style,bulletText=self.bulletText,frags=func(blPara,0,s))
>>
>> P1.blPara =
>> ParaLines(kind=1,lines=blPara.lines[0:s],aH=availHeight,aW=availWidth)
>> P1._JustifyLast = 1
>> P1._splitpara = 1
>> P1.height = height
>> P1.width = availWidth
>> P1.autoLeading = self.autoLeading # <-- BUGFIX
>> if style.firstLineIndent != 0:
>> style = deepcopy(style)
>> style.firstLineIndent = 0
>> P2=self.__class__(None,style,bulletText=None,frags=func(blPara,s,n))
>> P2.autoLeading = self.autoLeading # <-- BUGFIX
>> return [P1,P2]
>> -----------------8<---------------[cut here]
>>
>> .......
> Dirk are you setting the autoLeading directly on the Paragraph here? I
> know that we have allowed this for certain attributes. It's a slippery
> slope, but I guess since we've allowed this in the past it should go
> forward. Probably though since autoLeading can be on the style we ought
> to check for existence rather than assume that it's on the instance
> directly. I suggest the following patch.
>
>>
>> P1=self.__class__(None,style,bulletText=self.bulletText,frags=func(blPara,0,s))
>>
>> #this is a major hack
>> P1.blPara =
>> ParaLines(kind=1,lines=blPara.lines[0:s],aH=availHeight,aW=availWidth)
>> P1._JustifyLast = 1
>> P1._splitpara = 1
>> P1.height = height
>> P1.width = availWidth
>> if style.firstLineIndent != 0:
>> style = deepcopy(style)
>> style.firstLineIndent = 0
>>
>> P2=self.__class__(None,style,bulletText=None,frags=func(blPara,s,n))
> ######################
>> for a in ('autoLeading', #possible attributes that might be
>> directly on self.
>> ):
>> if hasattr(self,a):
>> setattr(P1,a,getattr(self,a))
>> setattr(P2,a,getattr(self,a))
> ######################
>> return [P1,P2]
>
> Can you see if that works for you?
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: reportlab_paragraph.py
Url: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20081211/d0cde032/attachment-0001.ksh>
More information about the reportlab-users
mailing list