[Checkins] SVN: z3c.rml/trunk/ - Created a new canvas directive called ``bookmark``.
Stephen Richter
cvs-admin at zope.org
Fri Dec 21 02:02:02 UTC 2012
Log message for revision 128833:
- Created a new canvas directive called ``bookmark``.
- Added ``img`` directive, which is a simple image flowable.
- Link support for rectangles.
Changed:
U z3c.rml/trunk/CHANGES.txt
U z3c.rml/trunk/RML-DIFFERENCES.txt
U z3c.rml/trunk/src/z3c/rml/canvas.py
U z3c.rml/trunk/src/z3c/rml/flowable.py
U z3c.rml/trunk/src/z3c/rml/platypus.py
-=-
Modified: z3c.rml/trunk/CHANGES.txt
===================================================================
--- z3c.rml/trunk/CHANGES.txt 2012-12-21 01:58:33 UTC (rev 128832)
+++ z3c.rml/trunk/CHANGES.txt 2012-12-21 02:02:02 UTC (rev 128833)
@@ -46,8 +46,10 @@
- Renamed ``bookmark`` to ``bookmarkPage``.
-- Created a new Canvas directive called ``bookmark``.
+- Created a new canvas directive called ``bookmark``.
+- Added ``img`` directive, which is a simple image flowable.
+
- Don't show "doc" namespace in reference snippets.
- Create a list of RML2PDF and z3c.rml differences.
@@ -60,7 +62,7 @@
- Implemented ``plugInGraphic`` which allows inserting graphics rendered in
Python.
-- Added `href` and `destination` to table cells.
+- Added `href` and `destination` to table cells and rectangles.
- Bug: Due to a logic error, bad directives were never properly detected and
logged about.
Modified: z3c.rml/trunk/RML-DIFFERENCES.txt
===================================================================
--- z3c.rml/trunk/RML-DIFFERENCES.txt 2012-12-21 01:58:33 UTC (rev 128832)
+++ z3c.rml/trunk/RML-DIFFERENCES.txt 2012-12-21 02:02:02 UTC (rev 128833)
@@ -33,7 +33,15 @@
- ``catchForms``: This feature requires PageCatcher, which is a ReportLab
commercial product and there is no Open Source alternative.
+- ``addMapping``: This is a useful API function that was supported in earlier
+ versions of RML2PDF. It is now gone, but this library still supports it.
+- ``drawing``: There is no documentation for this tag and I do not know what
+ it is supposed to do. Thus z3c.rml does not implement it.
+
+- ``widget``: There is no documentation for this tag and I do not know what it
+ is supposed to do. Thus z3c.rml does not implement it.
+
To be Done
----------
@@ -56,10 +64,6 @@
- blockTable: -repeatRows, -alignment
-- drawing
-
-- widget
-
- evalString
- image: -showBoundary, -preserveAspectRatio
@@ -72,9 +76,6 @@
- imageFigure
-- img
-
-
- checkBox
- letterBoxes
@@ -116,10 +117,6 @@
- length
-- param: -value
-
-- setFontSize (plain canvas op)
-
- log
- debug
@@ -136,6 +133,3 @@
- -pdfInclude
-- rectangle.: href and/or destination (Test 038)
-
-- -addMapping
Modified: z3c.rml/trunk/src/z3c/rml/canvas.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/canvas.py 2012-12-21 01:58:33 UTC (rev 128832)
+++ z3c.rml/trunk/src/z3c/rml/canvas.py 2012-12-21 02:02:02 UTC (rev 128833)
@@ -221,6 +221,17 @@
description=u'The radius of the rounded corners.',
required=False)
+ href = attr.Text(
+ title=u'Link URL',
+ description=u'When specified, the rectangle becomes a link to that URL.',
+ required=False)
+
+ destination = attr.Text(
+ title=u'Link Destination',
+ description=(u'When specified, the rectangle becomes a link to that '
+ u'destination.'),
+ required=False)
+
class Rectangle(CanvasRMLDirective):
signature = IRectangle
callable = 'rect'
@@ -229,8 +240,24 @@
def process(self):
if 'round' in self.element.keys():
self.callable = 'roundRect'
- super(Rectangle, self).process()
+ kwargs = dict(self.getAttributeValues(attrMapping=self.attrMapping))
+ canvas = attr.getManager(self, interfaces.ICanvasManager).canvas
+ # Create a link
+ url = kwargs.pop('href', None)
+ if url:
+ canvas.linkURL(
+ url,
+ (kwargs['x'], kwargs['y'],
+ kwargs['x']+kwargs['width'], kwargs['y']+kwargs['height']))
+ dest = kwargs.pop('destination', None)
+ if dest:
+ canvas.linkRect(
+ '', dest,
+ (kwargs['x'], kwargs['y'],
+ kwargs['x']+kwargs['width'], kwargs['y']+kwargs['height']))
+ # Render the rectangle
+ getattr(canvas, self.callable)(**kwargs)
class IGrid(interfaces.IRMLDirectiveSignature):
"""A shape to be drawn on the canvas."""
Modified: z3c.rml/trunk/src/z3c/rml/flowable.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/flowable.py 2012-12-21 01:58:33 UTC (rev 128832)
+++ z3c.rml/trunk/src/z3c/rml/flowable.py 2012-12-21 02:02:02 UTC (rev 128833)
@@ -838,6 +838,50 @@
frame = self.klass(flow.flow, **args)
self.parent.flow.append(frame)
+class IImage(interfaces.IRMLDirectiveSignature):
+ """An image."""
+
+ src = attr.Image(
+ title=u'Image Source',
+ description=u'The file that is used to extract the image data.',
+ onlyOpen=True,
+ required=True)
+
+ width = attr.Measurement(
+ title=u'Image Width',
+ description=u'The width of the image.',
+ required=False)
+
+ height = attr.Measurement(
+ title=u'Image Height',
+ description=u'The height the image.',
+ required=False)
+
+ mask = attr.Color(
+ title=u'Mask',
+ description=u'The color mask used to render the image.',
+ required=False)
+
+ vAlign = attr.Choice(
+ title=u'Vertical Alignment',
+ description=u'The vertical alignment of the image.',
+ choices=interfaces.VALIGN_TEXT_CHOICES,
+ required=False)
+
+class Image(Flowable):
+ signature = IImage
+ klass = reportlab.platypus.flowables.Image
+ attrMapping = {'src': 'filename'}
+
+ def process(self):
+ args = dict(self.getAttributeValues(attrMapping=self.attrMapping))
+ vAlign = args.pop('vAlign', None)
+ img = self.klass(**args)
+ if vAlign:
+ img.vAlign = vAlign
+ self.parent.flow.append(img)
+
+
class IImageAndFlowables(interfaces.IRMLDirectiveSignature):
"""An image with flowables around it."""
@@ -1051,6 +1095,35 @@
attrMapping = {'name': 'key', 'fitType': 'fit'}
+class IBookmark(interfaces.IRMLDirectiveSignature):
+ """
+ This creates a bookmark to the current page which can be referred to with
+ the given key elsewhere.
+ """
+
+ name = attr.Text(
+ title=u'Name',
+ description=u'The name of the bookmark.',
+ required=True)
+
+ x = attr.Measurement(
+ title=u'X Coordinate',
+ description=u'The x-position of the bookmark.',
+ default=0,
+ required=False)
+
+ y = attr.Measurement(
+ title=u'Y Coordinate',
+ description=u'The y-position of the bookmark.',
+ default=0,
+ required=False)
+
+class Bookmark(Flowable):
+ signature = IBookmark
+ klass = platypus.Bookmark
+ attrMapping = {'name': 'key', 'x': 'relativeX', 'y': 'relativeY'}
+
+
class ILink(interfaces.IRMLDirectiveSignature):
"""Place an internal link around a set of flowables."""
@@ -1287,11 +1360,13 @@
occurence.ZeroOrMore('condPageBreak', IConditionalPageBreak),
occurence.ZeroOrMore('keepInFrame', IKeepInFrame),
occurence.ZeroOrMore('keepTogether', IKeepTogether),
+ occurence.ZeroOrMore('img', IImage),
occurence.ZeroOrMore('imageAndFlowables', IImageAndFlowables),
occurence.ZeroOrMore('pto', IPTO),
occurence.ZeroOrMore('indent', IIndent),
occurence.ZeroOrMore('fixedSize', IFixedSize),
occurence.ZeroOrMore('bookmarkPage', IBookmarkPage),
+ occurence.ZeroOrMore('bookmark', IBookmark),
occurence.ZeroOrMore('link', ILink),
occurence.ZeroOrMore('hr', IHorizontalRow),
occurence.ZeroOrMore('showIndex', IShowIndex),
@@ -1330,11 +1405,13 @@
'condPageBreak': ConditionalPageBreak,
'keepInFrame': KeepInFrame,
'keepTogether': KeepTogether,
+ 'img': Image,
'imageAndFlowables': ImageAndFlowables,
'pto': PTO,
'indent': Indent,
'fixedSize': FixedSize,
'bookmarkPage': BookmarkPage,
+ 'bookmark': Bookmark,
'link': Link,
'hr': HorizontalRow,
'showIndex': ShowIndex,
Modified: z3c.rml/trunk/src/z3c/rml/platypus.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/platypus.py 2012-12-21 01:58:33 UTC (rev 128832)
+++ z3c.rml/trunk/src/z3c/rml/platypus.py 2012-12-21 02:02:02 UTC (rev 128833)
@@ -79,6 +79,11 @@
self.canv.bookmarkPage(*self.args, **self.kw)
+class Bookmark(BaseFlowable):
+ def draw(self):
+ self.canv.bookmarkHorizontal(*self.args, **self.kw)
+
+
class OutlineAdd(BaseFlowable):
def draw(self):
if self.kw.get('key', None) is None:
More information about the checkins
mailing list