dabo Commit
Revision 7230
Date: 2012-08-22 12:22:51 -0700 (Wed, 22 Aug 2012)
Author: Paul
Trac: http://trac.dabodev.com/changeset/7230
Changed:
U trunk/dabo/lib/reportWriter.py
Log:
If the contents of a Memo overflows the available space (height is fixed
too small), then an ellipse ("...") is printed after the length that can
be shown to indicate truncated data on the report.
However, if that data had embedded html tags like <b>bold</b> or <i>italic</i>,
an error would be raised from reportlab if the string happened to get
broken inside an open or closing tag (bare "<").
This commit fixes the problem by making sure the test string contains
matching tag brackets.
Note: the <b> and <i> tags are acceptable in Memo fields to provide simple
in-string formatting for emphasis, so it wouldn't have worked to simply
replace the "<" with "<".
Diff:
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py 2012-08-21 21:05:01 UTC (rev 7229)
+++ trunk/dabo/lib/reportWriter.py 2012-08-22 19:22:51 UTC (rev 7230)
@@ -1951,13 +1951,27 @@
break
else:
# Get the max. chars to
print in the alloted space that we can:
- for trial_len in
range(len(para)):
- p =
ParaClass("%s..." % para[:trial_len+1], s)
+ trial_len = 0
+ open_tag = 0
+ this_balanced_para = ""
+ while trial_len <
len(para):
+
last_balanced_para = this_balanced_para
+ trial_len += 1
+ para1 =
para[:trial_len]
+ if para1[-1] ==
"<":
+
open_tag += 1
+ elif para1[-1]
== ">":
+
open_tag -= 1
+ if open_tag > 0:
+ continue
+
this_balanced_para = para1
+ p =
ParaClass("%s..." % this_balanced_para, s)
p_height =
p.wrap(columnWidth-padLeft-padRight, None)[1]
if p_height >
availableHeight:
- p =
ParaClass("%s..." % para[:trial_len], s)
+ p =
ParaClass("%s..." % last_balanced_para, s)
p_height = p.wrap(columnWidth-padLeft-padRight, None)[1]
break
+
objNeededHeight +=
p_height
story.append((p,
p_height))
break
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]