Skip to content

Commit

Permalink
Okay, some more compatibility work. 4 more test suite files are more …
Browse files Browse the repository at this point in the history
…or less

passing now.
  • Loading branch information
strichter committed Mar 17, 2007
1 parent 09eb2e3 commit 22dc173
Show file tree
Hide file tree
Showing 9 changed files with 896 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/z3c/rml/attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,11 @@ class File(Text):
open = staticmethod(urllib.urlopen)
packageExtract = re.compile('^\[([0-9A-z_.]*)\]/(.*)$')

def __init__(self, name=None, default=DEFAULT):
doNotOpen = False

def __init__(self, name=None, default=DEFAULT, doNotOpen=False):
super(File, self).__init__(name, default)
self.doNotOpen = doNotOpen


def convert(self, value, context=None):
Expand All @@ -219,6 +222,8 @@ def convert(self, value, context=None):
modulepath, path = result.groups()
module = __import__(modulepath, {}, {}, (modulepath))
value = os.path.join(os.path.dirname(module.__file__), path)
if self.doNotOpen:
return value
# Open/Download the file
fileObj = self.open(value)
sio = cStringIO.StringIO(fileObj.read())
Expand Down
14 changes: 14 additions & 0 deletions src/z3c/rml/flowable.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ class BlockTableStyle(stylesheet.BlockTableStyle):

def process(self):
self.parent.style = copy.deepcopy(self.parent.style)
attrs = element.extractAttributes(self.attrs, self.element, self)
for name, value in attrs.items():
setattr(self.parent.style, name, value)
self.processSubElements(self.parent.style)


Expand Down Expand Up @@ -242,6 +245,9 @@ def process(self):
for name, value in attrs.items():
setattr(table, name, value)

# Must set keepWithNExt on table, since the style is not stored corr.
if hasattr(self.style, 'keepWithNext'):
table.keepWithNext = self.style.keepWithNext
self.parent.flow.append(table)


Expand Down Expand Up @@ -410,6 +416,13 @@ class HorizontalRow(Flowable):
('dash', attr.Sequence('dash', attr.Measurement())),
)

class OutlineAdd(Flowable):
klass = platypus.OutlineAdd
args = ( attr.TextNode(), attr.Text('key', None) )
kw = (
('level', attr.Int('level')),
('closed', attr.Bool('closed')),
)

class Flow(element.ContainerElement):

Expand All @@ -421,6 +434,7 @@ class Flow(element.ContainerElement):
'xpre': XPreformatted,
'plugInFlowable': PluginFlowable,
'barCodeFlowable': BarCodeFlowable,
'outlineAdd': OutlineAdd,
# Paragraph-Like Flowables
'title': Title,
'h1': Heading1,
Expand Down
29 changes: 21 additions & 8 deletions src/z3c/rml/platypus.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
__docformat__ = "reStructuredText"
import reportlab.platypus.flowables

class BaseFlowable(reportlab.platypus.flowables.Flowable):
def __init__(self, *args, **kw):
reportlab.platypus.flowables.Flowable.__init__(self)
self.args = args
self.kw = kw

def wrap(self, *args):
return (0, 0)

def draw(self):
pass

class Illustration(reportlab.platypus.flowables.Flowable):
def __init__(self, processor, width, height):
self.processor = processor
Expand All @@ -36,14 +48,15 @@ def draw(self):
drawing.process()
self.canv.restoreState()

class BookmarkPage(BaseFlowable):
def draw(self):
self.canv.bookmarkPage(*self.args, **self.kw)

class BookmarkPage(reportlab.platypus.flowables.Flowable):
def __init__(self, *args, **kw):
self.args = args
self.kw = kw

def wrap(self, *args):
return (0, 0)

class OutlineAdd(BaseFlowable):
def draw(self):
self.canv.bookmarkPage(*self.args, **self.kw)
title, key = self.args
if key is None:
key = str(hash(self))
self.canv.bookmarkPage(key)
self.canv.addOutlineEntry(title, key, **self.kw)
13 changes: 12 additions & 1 deletion src/z3c/rml/stylesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class ParagraphStyle(element.Element):
attr.Measurement('bulletFontSize'),
attr.Measurement('bulletIndent'),
attr.Color('textColor'),
attr.Color('backColor')
attr.Color('backColor'),
attr.Bool('keepWithNext')
)

def process(self):
Expand Down Expand Up @@ -196,6 +197,10 @@ def process(self):

class BlockTableStyle(element.ContainerElement):

attrs = (
attr.Bool('keepWithNext'),
)

subElements = {
'blockFont': BlockFont,
'blockLeading': BlockLeading,
Expand All @@ -215,8 +220,14 @@ class BlockTableStyle(element.ContainerElement):

def process(self):
id = attr.Text('id').get(self.element, context=self)
# Create Style
style = reportlab.platypus.tables.TableStyle()
attrs = element.extractAttributes(self.attrs, self.element, self)
for name, value in attrs.items():
setattr(style, name, value)
# Fill style
self.processSubElements(style)
# Add style to the manager
manager = attr.getManager(self, interfaces.IStylesManager)
manager.styles[id] = style

Expand Down
187 changes: 187 additions & 0 deletions src/z3c/rml/tests/input/images/cylinder.eps
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 223 178
%%Pages: 0
%%Creator: Sun Microsystems, Inc.
%%Title: none
%%CreationDate: none
%%LanguageLevel: 2
%%EndComments
%%BeginProlog
%%BeginResource: procset SDRes-Prolog 1.0 0
/b4_inc_state save def
/dict_count countdictstack def
/op_count count 1 sub def
userdict begin
0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit[] 0 setdash newpath
/languagelevel where {pop languagelevel 1 ne {false setstrokeadjust false setoverprint} if} if
/bdef {bind def} bind def
/c {setgray} bdef
/l {neg lineto} bdef
/rl {neg rlineto} bdef
/lc {setlinecap} bdef
/lj {setlinejoin} bdef
/lw {setlinewidth} bdef
/ml {setmiterlimit} bdef
/ld {setdash} bdef
/m {neg moveto} bdef
/ct {6 2 roll neg 6 2 roll neg 6 2 roll neg curveto} bdef
/r {rotate} bdef
/t {neg translate} bdef
/s {scale} bdef
/sw {show} bdef
/gs {gsave} bdef
/gr {grestore} bdef
/f {findfont dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def
currentdict end /NFont exch definefont pop /NFont findfont} bdef
/p {closepath} bdef
/sf {scalefont setfont} bdef
/ef {eofill}bdef
/pc {closepath stroke}bdef
/ps {stroke}bdef
/pum {matrix currentmatrix}bdef
/pom {setmatrix}bdef
/bs {/aString exch def /nXOfs exch def /nWidth exch def currentpoint nXOfs 0 rmoveto pum nWidth aString stringwidth pop div 1 scale aString show pom moveto} bdef
%%EndResource
%%EndProlog
%%BeginSetup
%%EndSetup
%%Page: 1 1
%%BeginPageSetup
%%EndPageSetup
pum
0.02837 0.0283 s
0 -6288 t
/tm matrix currentmatrix def
gs
tm setmatrix
-421 -635 t
1 1 s
421 635 m 8279 635 l 8279 6922 l 421 6922 l 421 635 l eoclip newpath
gs
421 635 m 8279 635 l 8279 6922 l 421 6922 l 421 635 l eoclip newpath
421 635 m 8280 635 l 8280 6923 l 421 6923 l 421 635 l eoclip newpath
0.000 c 7937 3937 m 7670 4026 l 7670 3848 l 7937 3937 l p ef
635 3937 m 7723 3937 l ps
6540 2095 m 6374 2323 l 6271 2178 l 6540 2095 l p ef
1651 5588 m 6366 2219 l ps
3948 1079 m 4037 1346 l 3859 1346 l 3948 1079 l p ef
3948 6032 m 3948 5981 l ps
3948 5930 m 3948 5879 l ps
3948 5828 m 3948 5777 l ps
3948 5726 m 3948 5675 l ps
3948 5624 m 3948 5573 l ps
3948 5522 m 3948 5471 l ps
3948 5420 m 3948 5369 l ps
3948 5318 m 3948 5267 l ps
3948 5216 m 3948 5165 l ps
3948 5114 m 3948 5063 l ps
3948 5012 m 3948 4961 l ps
3948 4910 m 3948 4859 l ps
3948 4808 m 3948 4757 l ps
3948 4706 m 3948 4655 l ps
3948 4604 m 3948 4553 l ps
3948 4502 m 3948 4451 l ps
3948 4400 m 3948 4349 l ps
3948 4298 m 3948 4247 l ps
3948 4196 m 3948 4145 l ps
3948 4094 m 3948 4043 l ps
3948 3992 m 3948 3941 l ps
3948 3890 m 3948 3839 l ps
3948 3788 m 3948 3737 l ps
3948 3686 m 3948 3635 l ps
3948 3584 m 3948 3533 l ps
3948 3482 m 3948 3431 l ps
3948 3380 m 3948 3329 l ps
3948 3278 m 3948 3227 l ps
3948 3176 m 3948 3125 l ps
3948 3074 m 3948 3023 l ps
3948 2972 m 3948 2921 l ps
3948 2870 m 3948 2819 l ps
3948 2768 m 3948 2717 l ps
3948 2666 m 3948 2615 l ps
3948 2564 m 3948 2513 l ps
3948 2462 m 3948 2411 l ps
3948 2360 m 3948 2309 l ps
3948 2258 m 3948 2207 l ps
3948 2156 m 3948 2105 l ps
3948 2054 m 3948 2003 l ps
3948 1952 m 3948 1901 l ps
3948 1850 m 3948 1799 l ps
3948 1748 m 3948 1697 l ps
3948 1646 m 3948 1595 l ps
3948 1544 m 3948 1493 l ps
3948 1442 m 3948 1391 l ps
3948 1340 m 3948 1293 l ps
gs
gs
pum
7843 4359 t
5 -157 m 5 -157 5 -157 5 -151 ct 18 -151 24 -148 41 -123 ct 41 -123 41 -123 71 -80 ct
71 -80 71 -80 38 -36 ct 20 -12 15 -7 6 -6 ct 6 -6 6 -6 6 0 ct 6 0 6 0 56 0 ct 56 0 56 0 56 -6 ct
46 -6 41 -12 41 -17 ct 41 -19 45 -25 53 -36 ct 53 -36 53 -36 77 -70 ct 77 -70 77 -70 100 -36 ct
107 -25 111 -19 111 -16 ct 111 -10 105 -6 96 -6 ct 96 -6 96 -6 96 0 ct 96 0 96 0 169 0 ct
169 0 169 0 169 -7 ct 156 -7 152 -8 133 -36 ct 133 -36 133 -36 94 -92 ct 94 -92 94 -92 115 -122 ct
133 -145 140 -151 152 -151 ct 152 -151 152 -151 152 -157 ct 152 -157 152 -157 100 -157 ct
100 -157 100 -157 100 -151 ct 109 -151 112 -147 112 -143 ct 112 -140 108 -133 100 -121 ct
100 -121 100 -121 87 -103 ct 87 -103 87 -103 76 -121 ct 66 -137 65 -139 65 -142 ct
65 -148 68 -151 77 -151 ct 77 -151 77 -151 77 -157 ct 77 -157 77 -157 5 -157 ct
p ef
pom
gr
gr
gs
gs
pum
6545 2355 t
2 -158 m 2 -158 2 -158 2 -152 ct 15 -149 21 -143 29 -126 ct 29 -126 29 -126 85 -7 ct
85 -7 85 -7 74 21 ct 66 41 58 47 51 47 ct 30 40 30 40 27 40 ct 17 40 10 47 10 56 ct
10 66 19 76 33 76 ct 51 76 73 60 85 29 ct 85 29 85 29 148 -128 ct 155 -146 159 -150 171 -152 ct
171 -152 171 -152 171 -158 ct 171 -158 171 -158 121 -158 ct 121 -158 121 -158 121 -152 ct
132 -152 136 -150 136 -143 ct 136 -138 135 -134 133 -129 ct 133 -129 133 -129 99 -42 ct
99 -42 99 -42 61 -121 ct 57 -129 55 -135 55 -140 ct 55 -150 64 -152 74 -152 ct
74 -152 74 -152 74 -158 ct 74 -158 74 -158 2 -158 ct p ef
pom
gr
gr
gs
gs
pum
3638 1254 t
145 -48 m 145 -48 145 -48 139 -48 ct 136 -17 131 -12 101 -12 ct 101 -12 101 -12 44 -12 ct
44 -12 44 -12 148 -151 ct 148 -151 148 -151 148 -157 ct 148 -157 148 -157 18 -157 ct
18 -157 18 -157 17 -113 ct 17 -113 17 -113 24 -113 ct 26 -144 37 -145 59 -145 ct
59 -145 59 -145 110 -145 ct 110 -145 110 -145 7 -6 ct 7 -6 7 -6 7 0 ct 7 0 7 0 144 0 ct
144 0 144 0 145 -48 ct p ef
pom
gr
gr
25 lw 1 lj 3962 2032 m 3314 2032 2787 1960 2787 1873 ct 2787 1786 3314 1714 3962 1714 ct
4610 1714 5137 1786 5137 1873 ct 5137 1960 4610 2032 3962 2032 ct pc
5137 2139 m 5087 2221 4581 2285 3966 2286 ct 3318 2286 2791 2214 2791 2127 ct
2791 2126 2791 2126 2791 2126 ct ps
3949 1905 m 3949 1270 l ps
3949 6506 m 3949 5871 l ps
2788 1841 m 2788 2159 l ps
5116 1841 m 5116 2159 l ps
5137 5839 m 5087 5921 4581 5985 3966 5986 ct 3318 5986 2791 5914 2791 5827 ct
2791 5826 2791 5826 2791 5826 ct ps
2788 5541 m 2788 5859 l ps
5116 5541 m 5116 5859 l ps
3659 2286 m 3659 5524 l ps
4259 2286 m 4259 5524 l ps
4291 5531 m 4272 5563 4137 5588 3976 5588 ct 3813 5588 3678 5562 3660 5531 ct
ps
4268 5399 m 4759 5418 5120 5480 5120 5552 ct 5120 5639 4593 5711 3945 5711 ct
3297 5711 2770 5639 2770 5552 ct 2770 5477 3151 5414 3664 5397 ct ps
gr
gs
421 635 m 8279 635 l 8279 6922 l 421 6922 l 421 635 l eoclip newpath
gr
gr
0 6288 t
pom
count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat b4_inc_state restore
%%PageTrailer
%%Trailer
%%EOF

0 comments on commit 22dc173

Please sign in to comment.