Skip to content

Commit

Permalink
- Renamed bookmark to bookmarkPage.
Browse files Browse the repository at this point in the history
- Created a new Canvas directive called ``bookmark``
  • Loading branch information
strichter committed Dec 20, 2012
1 parent 3fed4f5 commit 22dd294
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ CHANGES

- Added ``encName`` attribute to ``registerCidFont`` directive.

- Renamed ``bookmark`` to ``bookmarkPage``.

- Created a new Canvas directive called ``bookmark``.

- Don't show "doc" namespace in reference snippets.

- Create a list of RML2PDF and z3c.rml differences.
Expand Down
12 changes: 0 additions & 12 deletions RML-DIFFERENCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,14 @@ naming.

- frame: -*Padding, -showBoundary

- getName

- color: value -> RGB

- outlineAdd: -key

- cropMarks

- bookmark: -fitType, -left, -top, -right, -zoom, x, y

- bookmarkPage

- join

- length

- param: -value

- registerCidFont: +encName

- setFontSize (plain canvas op)

- log
Expand Down
48 changes: 47 additions & 1 deletion src/z3c/rml/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,48 @@ def process(self):
canvas.setDash(kw['dash'])


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)

fit = attr.Choice(
title=u'Fit',
description=u'The Fit Type.',
choices=('XYZ', 'Fit', 'FitH', 'FitV', 'FitR'),
required=False)

zoom = attr.Float(
title=u'Zoom',
description=u'The zoom level when clicking on the bookmark.',
required=False)

x = attr.Measurement(
title=u'X-Position',
description=u'The x-position.',
required=False)

y = attr.Measurement(
title=u'Y-Position',
description=u'The y-position.',
required=False)

class Bookmark(CanvasRMLDirective):
signature = IBookmark

def process(self):
args = dict(self.getAttributeValues())
canvas = attr.getManager(self, interfaces.ICanvasManager).canvas
args['left'], args['top'] = canvas.absolutePosition(args['x'], args['y'])
canvas.bookmarkPage(**args)


class IDrawing(interfaces.IRMLDirectiveSignature):
"""A container directive for all directives that draw directly on the
cnavas."""
Expand Down Expand Up @@ -820,6 +862,8 @@ class IDrawing(interfaces.IRMLDirectiveSignature):
occurence.ZeroOrMore('pieChart', chart.IPieChart),
occurence.ZeroOrMore('pieChart3D', chart.IPieChart3D),
occurence.ZeroOrMore('spiderChart', chart.ISpiderChart),
# Misc
occurence.ZeroOrMore('bookmark', IBookmark),
)

class Drawing(directive.RMLDirective):
Expand Down Expand Up @@ -868,7 +912,9 @@ class Drawing(directive.RMLDirective):
'linePlot3D': chart.LinePlot3D,
'pieChart': chart.PieChart,
'pieChart3D': chart.PieChart3D,
'spiderChart': chart.SpiderChart
'spiderChart': chart.SpiderChart,
# Misc
'bookmark': Bookmark,
}


Expand Down
34 changes: 17 additions & 17 deletions src/z3c/rml/flowable.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ def process(self):
self.parent.flow.append(frame)


class IBookmark(interfaces.IRMLDirectiveSignature):
class IBookmarkPage(interfaces.IRMLDirectiveSignature):
"""
This creates a bookmark to the current page which can be referred to with
the given key elsewhere.
Expand All @@ -1000,25 +1000,25 @@ class IBookmark(interfaces.IRMLDirectiveSignature):
description=u'The name of the bookmark.',
required=True)

fitType = attr.Choice(
title=u'Fit Type',
fit = attr.Choice(
title=u'Fit',
description=u'The Fit Type.',
choices=('Fit', 'FitH', 'FitV', 'FitR'),
choices=('XYZ', 'Fit', 'FitH', 'FitV', 'FitR'),
required=False)

left = attr.Measurement(
title=u'Left',
description=u'The left position.',
top = attr.Measurement(
title=u'Top',
description=u'The top position.',
required=False)

right = attr.Measurement(
title=u'Right',
description=u'The right position.',
bottom = attr.Measurement(
title=u'Bottom',
description=u'The bottom position.',
required=False)

top = attr.Measurement(
title=u'Top',
description=u'The top position.',
left = attr.Measurement(
title=u'Left',
description=u'The left position.',
required=False)

right = attr.Measurement(
Expand All @@ -1031,8 +1031,8 @@ class IBookmark(interfaces.IRMLDirectiveSignature):
description=u'The zoom level when clicking on the bookmark.',
required=False)

class Bookmark(Flowable):
signature = IBookmark
class BookmarkPage(Flowable):
signature = IBookmarkPage
klass = platypus.BookmarkPage
attrMapping = {'name': 'key', 'fitType': 'fit'}

Expand Down Expand Up @@ -1277,7 +1277,7 @@ class IFlow(interfaces.IRMLDirectiveSignature):
occurence.ZeroOrMore('pto', IPTO),
occurence.ZeroOrMore('indent', IIndent),
occurence.ZeroOrMore('fixedSize', IFixedSize),
occurence.ZeroOrMore('bookmark', IBookmark),
occurence.ZeroOrMore('bookmarkPage', IBookmarkPage),
occurence.ZeroOrMore('link', ILink),
occurence.ZeroOrMore('hr', IHorizontalRow),
occurence.ZeroOrMore('showIndex', IShowIndex),
Expand Down Expand Up @@ -1320,7 +1320,7 @@ class Flow(directive.RMLDirective):
'pto': PTO,
'indent': Indent,
'fixedSize': FixedSize,
'bookmark': Bookmark,
'bookmarkPage': BookmarkPage,
'link': Link,
'hr': HorizontalRow,
'showIndex': ShowIndex,
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/rml/reference.pt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
<outlineAdd level="1" tal:content="directive/name">
Element Name
</outlineAdd>
<bookmark tal:attributes="name directive/id"/>
<bookmarkPage tal:attributes="name directive/id"/>
<para style="deprecation"
tal:condition="directive/deprecated">
<b>Deprecated:</b>
Expand Down
4 changes: 2 additions & 2 deletions src/z3c/rml/tests/input/tag-bookmark.rml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
<font face="Courier">&lt;link&gt;</font>
Tag Demo
</title>
<bookmark name="TITLE" doc:example="" />
<bookmarkPage name="TITLE" doc:example="" />
<link destination="PAGE_1"
boxStrokeColor="red" boxStrokeWidth="1" boxStrokeDashArray="1 2"
doc:example="">
<para>Go to page 1 now!</para>
</link>
<nextPage/>
<bookmark
<bookmarkPage
name="PAGE_1" fitType="fitv" zoom="2"
left="2cm" right="10cm" top="20cm"
doc:example=""
Expand Down

0 comments on commit 22dd294

Please sign in to comment.