Skip to content

Commit

Permalink
Added tests for viewer options/preferences. Fixed bugs that were reve…
Browse files Browse the repository at this point in the history
…aled.

fixed a test due to latest optimizations.

Re-generated the RML reference with the latest version number.
  • Loading branch information
strichter committed Mar 7, 2013
1 parent 761f42e commit 01f8195
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ CHANGES
do things like "Page X of Y". This only works in the ``drawString`` and
``para`` elements. [Kyle MacFarlane]

- General performance improvements. [Kyle MacFarlane]

- Improved performance by not applying a copy of the default style to every
table cell and also by not even trying to initialise the attributes if lxml
says they don't exist. [Kyle MacFarlane]
Expand Down
14 changes: 14 additions & 0 deletions src/z3c/rml/attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ class Boolean(BaseChoice):
'1': True, '0': False,
}

class TextBoolean(BaseChoice):
'''A boolean value as text.
ReportLab sometimes exposes low-level APIs, so we have to provide values
that are directly inserted into the PDF.
For "true" the values "true", "yes", and "1" are allowed. For "false", the
values "false", "no", "1" are allowed.
'''
choices = {'true': 'true', 'false': 'false',
'yes': 'true', 'no': 'false',
'1': 'true', '0': 'false',
}


class BooleanWithDefault(Boolean):
'''This is a boolean field that can also receive the value "default".'''
Expand Down
14 changes: 7 additions & 7 deletions src/z3c/rml/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,36 +450,36 @@ class IDocInit(interfaces.IRMLDirectiveSignature):
description=u'A flag when set shows crop marks on the page.',
required=False)

hideToolbar = attr.Boolean(
hideToolbar = attr.TextBoolean(
title=u'Hide Toolbar',
description=(u'A flag indicating that the toolbar is hidden in '
u'the viewer.'),
required=False)

hideMenubar = attr.Boolean(
hideMenubar = attr.TextBoolean(
title=u'Hide Menubar',
description=(u'A flag indicating that the menubar is hidden in '
u'the viewer.'),
required=False)

hideWindowUI = attr.Boolean(
hideWindowUI = attr.TextBoolean(
title=u'Hide Window UI',
description=(u'A flag indicating that the window UI is hidden in '
u'the viewer.'),
required=False)

fitWindow = attr.Boolean(
title=u'Fir Window',
fitWindow = attr.TextBoolean(
title=u'Fit Window',
description=u'A flag indicating that the page fits in the viewer.',
required=False)

centerWindow = attr.Boolean(
centerWindow = attr.TextBoolean(
title=u'Center Window',
description=(u'A flag indicating that the page fits is centered '
u'in the viewer.'),
required=False)

displayDocTitle = attr.Boolean(
displayDocTitle = attr.TextBoolean(
title=u'Display Doc Title',
description=(u'A flag indicating that the document title is displayed '
u'in the viewer.'),
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 @@ -112,7 +112,7 @@
</drawCenteredString>
<setFont name="Helvetica" size="24" />
<drawCenteredString x="10.5cm" y="18.5cm">
Version 2.0
Version 2.1
</drawCenteredString>
</pageGraphics>
<frame id="main" x1="3cm" y1="2cm" width="17cm" height="25.7cm" />
Expand Down
6 changes: 5 additions & 1 deletion src/z3c/rml/rlfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""ReportLab fixups.
"""
__docformat__ = "reStructuredText"
from reportlab.pdfbase import pdfform
from reportlab.pdfbase import pdfform, pdfmetrics, ttfonts
from reportlab.pdfbase.pdfpattern import PDFPattern
from reportlab.graphics import testshapes

Expand All @@ -30,6 +30,10 @@ def resetFonts():
# testshapes._setup registers the Vera fonts every time which is a little
# slow on all platforms. On Windows it lists the entire system font
# directory and registers them all which is very slow.
pdfmetrics.registerFont(ttfonts.TTFont("Vera", "Vera.ttf"))
pdfmetrics.registerFont(ttfonts.TTFont("VeraBd", "VeraBd.ttf"))
pdfmetrics.registerFont(ttfonts.TTFont("VeraIt", "VeraIt.ttf"))
pdfmetrics.registerFont(ttfonts.TTFont("VeraBI", "VeraBI.ttf"))
for f in ('Times-Roman','Courier','Helvetica','Vera', 'VeraBd', 'VeraIt',
'VeraBI'):
if f not in testshapes._FONTS:
Expand Down
Binary file modified src/z3c/rml/rml-reference.pdf
Binary file not shown.
Binary file modified src/z3c/rml/tests/expected/rml-examples-029-keepinframe.pdf
Binary file not shown.
Binary file not shown.
35 changes: 35 additions & 0 deletions src/z3c/rml/tests/input/tag-docinit-viewer-options.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE document SYSTEM "rml.dtd">

<document
filename="tag-docinit-viewer-options.pdf"
xmlns:doc="http://namespaces.zope.org/rml/doc">

<docinit
hideToolbar="true"
hideMenubar="true"
hideWindowUI="true"
fitWindow="true"
centerWindow="true"
displayDocTitle="true"
nonFullScreenPageMode="UseOutlines"
direction="L2R"
viewArea="MediaBox"
viewClip="MediaBox"
printArea="MediaBox"
printClip="MediaBox"
printScaling="None"
doc:example="">
</docinit>

<template>
<pageTemplate id="main">
<frame id="first" x1="1cm" y1="1cm" width="19cm" height="26cm"/>
</pageTemplate>
</template>

<story>
<h1>Hello RML users!</h1>
</story>

</document>

0 comments on commit 01f8195

Please sign in to comment.