git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193837 13f79535-47bb-0310-9956-ffa450edef68tags/pre-columns
@@ -6,79 +6,679 @@ | |||
<fo:layout-master-set> | |||
<!-- layout for the first page --> | |||
<!-- page layout --> | |||
<fo:simple-page-master master-name="first" | |||
page-height="29.7cm" | |||
page-width="21cm" | |||
margin-top="1cm" | |||
margin-top="2.5cm" | |||
margin-bottom="2cm" | |||
margin-left="2.5cm" | |||
margin-right="2.5cm"> | |||
<fo:region-body margin-top="3cm"/> | |||
<fo:region-before extent="3cm"/> | |||
<fo:region-after extent="1.5cm"/> | |||
<fo:region-body/> | |||
</fo:simple-page-master> | |||
<fo:page-sequence-master master-name="basicPSM" > | |||
<fo:repeatable-page-master-alternatives> | |||
<fo:conditional-page-master-reference master-name="first" | |||
page-position="first" /> | |||
</fo:repeatable-page-master-alternatives> | |||
</fo:page-sequence-master> | |||
</fo:layout-master-set> | |||
<!-- end: defines page layout --> | |||
<!-- actual layout --> | |||
<fo:page-sequence master-name="basicPSM"> | |||
<fo:page-sequence master-name="first"> | |||
<fo:flow flow-name="xsl-region-body"> | |||
<!-- Normal text --> | |||
<fo:block font-size="16pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
Leader examples | |||
</fo:block> | |||
<fo:block font-size="12pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-before.optimum="5pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
leader with leader-pattern="space" | |||
</fo:block> | |||
<!-- Inserts a leader (space) --> | |||
<fo:block text-align="start">Entry 1 | |||
<fo:leader leader-pattern="space" | |||
leader-length.maximum="6cm"/>p. 12 | |||
</fo:block> | |||
<!-- Inserts a leader (space) --> | |||
<fo:block text-align="start">Entry 2 | |||
<fo:leader leader-pattern="space" | |||
leader-length.maximum="6cm"/>p. 24 | |||
</fo:block> | |||
<!-- Inserts a leader (space) --> | |||
<fo:block text-align="start">Left side | |||
<fo:leader leader-pattern="space" | |||
leader-length.maximum="5.5cm"/>middle | |||
<fo:leader leader-pattern="space" | |||
leader-length.maximum="5.5cm"/>right side | |||
</fo:block> | |||
<fo:block font-size="12pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-before.optimum="5pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
Using fo:leader with leader-pattern="dots" | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 1 | |||
<fo:leader leader-pattern="dots" | |||
leader-length.maximum="6cm"/>p. 12 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 2 | |||
<fo:leader leader-pattern="dots" | |||
leader-length.maximum="6cm"/>p. 24 | |||
</fo:block> | |||
<fo:block font-size="12pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-before.optimum="5pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
Using fo:leader with leader-pattern="dots" and leader-pattern-width="5pt" and "8pt" | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 1 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="5pt" | |||
leader-length.maximum="6cm"/>p. 12 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 2 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="5pt" | |||
leader-length.maximum="6cm"/>p. 24 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 1 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm"/>p. 12 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 2 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm"/>p. 24 | |||
</fo:block> | |||
<fo:block font-size="12pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-before.optimum="5pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
Using fo:leader with leader-pattern="dots" in a list | |||
</fo:block> | |||
<fo:block text-align="start" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt"> | |||
Using fo:leader with leader-pattern="dots", leader-pattern-width="5pt" and "8pt", leader-alignment="reference-area" | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 1 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="5pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="6cm"/>p. 12 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 2 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="5pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="6cm"/>p. 24 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 3 is longer | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="5pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="6cm"/>p. 36 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 4 is even longer | |||
<fo:leader leader-pattern="dots" | |||
leader-alignment="reference-area" | |||
leader-pattern-width="5pt" | |||
leader-length.maximum="6cm"/>p. 48 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">1 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm" | |||
leader-alignment="reference-area"/>p. 12 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 2 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm" | |||
leader-alignment="reference-area"/>p. 24 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 3 is longer | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm" | |||
leader-alignment="reference-area"/>p. 36 | |||
</fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 4 is even longer | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm" | |||
leader-alignment="reference-area"/>p. 48 | |||
</fo:block> | |||
<!-- list start --> | |||
<!-- use provisional-distance-between-starts to define | |||
the distance between the start of the label and the item text | |||
use provisional-label-separation to define the distance between | |||
the end of the item label and the start of item text | |||
--> | |||
<fo:list-block provisional-distance-between-starts="0.3cm" | |||
provisional-label-separation="0.15cm"> | |||
<!-- list item --> | |||
<fo:list-item> | |||
<!-- insert a bullet --> | |||
<fo:list-item-label> | |||
<fo:block><fo:inline font-size="10pt" font-family="Symbol">·</fo:inline></fo:block> | |||
</fo:list-item-label> | |||
<!-- list text --> | |||
<fo:list-item-body> | |||
<fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 1 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="5pt" | |||
leader-length.maximum="6cm"/>p. 12 | |||
</fo:block> | |||
</fo:block> | |||
</fo:list-item-body> | |||
</fo:list-item> | |||
<!-- list item --> | |||
<fo:list-item> | |||
<!-- insert a bullet --> | |||
<fo:list-item-label> | |||
<fo:block><fo:inline font-size="10pt" font-family="Symbol">·</fo:inline></fo:block> | |||
</fo:list-item-label> | |||
<!-- list text --> | |||
<fo:list-item-body> | |||
<fo:block> | |||
<!-- Inserts a leader (dots) --> | |||
<fo:block text-align="start">Entry 2 | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="5pt" | |||
leader-length.maximum="6cm"/>p. 24 | |||
</fo:block> | |||
</fo:block> | |||
</fo:list-item-body> | |||
</fo:list-item> | |||
</fo:list-block> | |||
<!-- list end --> | |||
<fo:block font-size="12pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-before.optimum="5pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a | |||
W3C Recommendation. It is a stable document and may be used as reference material or cited as a normative reference from | |||
another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its | |||
widespread deployment. - Here comes a line (thickness: 3pt). | |||
Using fo:leader with leader-pattern="dots" in a table | |||
</fo:block> | |||
<!-- table start --> | |||
<fo:table> | |||
<fo:table-column column-width="20mm"/> | |||
<fo:table-column column-width="60mm"/> | |||
<fo:table-column column-width="50mm"/> | |||
<fo:table-body> | |||
<fo:table-row> | |||
<fo:table-cell ><fo:block>Entry 1</fo:block></fo:table-cell> | |||
<fo:table-cell > | |||
<fo:block text-align="start"> | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm"/> | |||
</fo:block> | |||
</fo:table-cell> | |||
<fo:table-cell ><fo:block>p. 12</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
<fo:table-row> | |||
<fo:table-cell ><fo:block>Entry 2 </fo:block></fo:table-cell> | |||
<fo:table-cell > | |||
<fo:block text-align="start"> | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm"/> | |||
</fo:block> | |||
</fo:table-cell> | |||
<fo:table-cell ><fo:block>p. 24</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
<fo:table-row> | |||
<fo:table-cell ><fo:block>Entry 3 </fo:block></fo:table-cell> | |||
<fo:table-cell > | |||
<fo:block text-align="start"> | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.maximum="6cm"/> | |||
</fo:block> | |||
</fo:table-cell> | |||
<fo:table-cell ><fo:block>p. 36</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
</fo:table-body> | |||
</fo:table> | |||
<!-- table end --> | |||
<fo:block font-size="12pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-before.optimum="5pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
Leader with leader-pattern="rule" | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="center"> | |||
<fo:block text-align="start">text before the rule (start) | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="3.0pt" | |||
rule-thickness="3.0pt" | |||
leader-length="6cm" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt" | |||
start-indent="1.5cm" | |||
end-indent="2cm"/> | |||
end-indent="2cm" | |||
background-color="blue" | |||
color="yellow"/> | |||
text after the rule | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="center">text before the rule (center) | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="3.0pt" | |||
leader-length="6cm" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt" | |||
start-indent="1.5cm" | |||
end-indent="2cm" | |||
background-color="blue" | |||
color="yellow"/> | |||
text after the rule | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="end">text before the rule (end) | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="3.0pt" | |||
leader-length="6cm" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt" | |||
start-indent="1.5cm" | |||
end-indent="2cm" | |||
background-color="blue" | |||
color="yellow"/> | |||
text after the rule | |||
</fo:block> | |||
<fo:block font-size="12pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-before.optimum="5pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
Here are 3 fo:leader with the property rule and no text | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="start" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt"> | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="3.0pt" | |||
leader-length="6cm"/> | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="center" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt"> | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="3.0pt" | |||
leader-length="6cm"/> | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="end" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt"> | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="3.0pt" | |||
leader-length="6cm"/> | |||
</fo:block> | |||
<!-- Normal text --> | |||
<fo:block font-size="12pt" | |||
font-family="sans-serif" | |||
line-height="15pt" | |||
space-before.optimum="5pt" | |||
space-after.optimum="3pt" | |||
text-align="start"> | |||
This document specifies a syntax created by subsetting an existing, widely used international text processing standard | |||
(Standard Generalized Markup Language, ISO 8879:1986(E) as amended and corrected) for use on the World Wide Web. It | |||
is a product of the W3C XML Activity, details of which can be found at http://www.w3.org/XML. A list of current W3C | |||
Recommendations and other technical documents can be found at http://www.w3.org/TR. - Here comes a line (thickness: 1pt (default)) | |||
Here are 4 fo:leader with increasing rule-thickness (1pt, 2pt, 3pt, 4pt) | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="start"> | |||
<fo:block text-align="center" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt"> | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="1.0pt" | |||
leader-length.maximum="6cm"/> | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="center" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt" | |||
start-indent="1.5cm" | |||
end-indent="2cm"/> | |||
space-after.optimum="12pt"> | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="2.0pt" | |||
leader-length.maximum="6cm"/> | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="center" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt"> | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="3.0pt" | |||
leader-length.maximum="6cm"/> | |||
</fo:block> | |||
<!-- Inserts a leader (rule). Because leader is an inline fo you have | |||
to wrap it into a block element --> | |||
<fo:block text-align="center" | |||
space-before.optimum="12pt" | |||
space-after.optimum="12pt"> | |||
<fo:leader leader-pattern="rule" | |||
rule-thickness="4.0pt" | |||
leader-length.maximum="6cm"/> | |||
</fo:block> | |||
<fo:block text-align="center" | |||
font-size="16pt" | |||
space-before.optimum="16pt" | |||
space-after.optimum="12pt"> | |||
Using leader in combination with justified text | |||
</fo:block> | |||
<fo:block text-align="justify">Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here comes the leader (dots width 8pt): | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-length.minimum="2cm" | |||
leader-length.maximum="5cm"/>Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here is some longer text. Here is some longer text. | |||
</fo:block> | |||
<fo:block text-align="justify">Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here comes the leader (dots width 5pt): | |||
<fo:leader leader-pattern="dots" | |||
leader-pattern-width="5pt" | |||
leader-length.minimum="2cm" | |||
leader-length.maximum="5cm"/>Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here is some longer text. Here is some longer text. | |||
</fo:block> | |||
<fo:block text-align="justify">Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here comes the leader (dots): | |||
<fo:leader leader-pattern="dots" | |||
leader-length.minimum="2cm" | |||
leader-length.maximum="5cm"/>Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here is some longer text. Here is some longer text. | |||
</fo:block> | |||
<fo:block text-align="justify">Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here comes the leader (rule): | |||
<fo:leader leader-pattern="rule" | |||
leader-length.minimum="2cm" | |||
leader-length.maximum="5cm"/>Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here is some longer text. Here is some longer text. | |||
</fo:block> | |||
<fo:block text-align="justify">Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here comes the leader (space): | |||
<fo:leader leader-pattern="space" | |||
leader-length.minimum="2cm" | |||
leader-length.maximum="5cm"/>Here is some longer text. Here is some longer text. | |||
Here is some longer text. Here is some longer text. Here is some longer text. | |||
</fo:block> | |||
<fo:block text-align="center" | |||
font-size="16pt" | |||
space-before.optimum="16pt" | |||
space-after.optimum="12pt"> | |||
Table of Content | |||
</fo:block> | |||
<fo:block text-align="start" | |||
font-size="10pt" | |||
space-after.optimum="12pt"> | |||
shows the use of leader properties in combination to build a table of content. | |||
Following values are used for the leader: | |||
leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm" | |||
</fo:block> | |||
<!-- Here starts the table --> | |||
<fo:table> | |||
<fo:table-column column-width="1cm"/> | |||
<fo:table-column column-width="14.2cm"/> | |||
<fo:table-column column-width="0.3cm"/> | |||
<fo:table-body font-size="10pt" font-family="sans-serif"> | |||
<fo:table-row line-height="12pt"> | |||
<fo:table-cell><fo:block text-align="end">A) </fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="start">What is FOP?<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="end">1</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
<fo:table-row line-height="12pt"> | |||
<fo:table-cell><fo:block text-align="end">B) </fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="start">Downloading FOP<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="end">2</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
<fo:table-row line-height="12pt"> | |||
<fo:table-cell><fo:block text-align="end" >C) </fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="start">Running FOP<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="end">3</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
<fo:table-row line-height="12pt"> | |||
<fo:table-cell><fo:block text-align="end">D) </fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="start">Embedding FOP<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="end">4</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
<fo:table-row line-height="12pt"> | |||
<fo:table-cell><fo:block text-align="end">E) </fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="start">What is Implemented?<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block></fo:table-cell> | |||
<fo:table-cell><fo:block text-align="end">5</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
</fo:table-body> | |||
</fo:table> | |||
<fo:block text-align="center" | |||
font-size="16pt" | |||
space-before.optimum="16pt" | |||
space-after.optimum="12pt"> | |||
Table of Content 2 | |||
</fo:block> | |||
<fo:block text-align="start" | |||
font-size="10pt" | |||
space-after.optimum="12pt"> | |||
shows the use of leader-length.minimum in the middle column. Values are increased from 0cm (default) | |||
to 0.5 and then to 1cm | |||
</fo:block> | |||
<!-- Here starts the table --> | |||
<fo:table> | |||
<fo:table-column column-width="1cm"/> | |||
<fo:table-column column-width="7cm"/> | |||
<fo:table-column column-width="2cm"/> | |||
<fo:table-body font-size="10pt" font-family="sans-serif"> | |||
<fo:table-row line-height="12pt"> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="end">A)</fo:block></fo:table-cell> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="start">What is FOP doing here in the middle?<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.optimum="5cm" | |||
leader-length.maximum="7cm"/></fo:block></fo:table-cell> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="end">1</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
<fo:table-row line-height="12pt"> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="end">A)</fo:block></fo:table-cell> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="start">What is FOP doing here in the middle?<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.minimum="0.5cm" | |||
leader-length.optimum="5cm" | |||
leader-length.maximum="7cm"/></fo:block></fo:table-cell> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="end">1</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
<fo:table-row line-height="12pt"> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="end">A)</fo:block></fo:table-cell> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="start">What is FOP doing here in the middle?<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.minimum="1cm" | |||
leader-length.optimum="5cm" | |||
leader-length.maximum="7cm"/></fo:block></fo:table-cell> | |||
<fo:table-cell border-width="0.5mm"><fo:block text-align="end">1</fo:block></fo:table-cell> | |||
</fo:table-row> | |||
</fo:table-body> | |||
</fo:table> | |||
<fo:block text-align="center" | |||
font-size="16pt" | |||
space-before.optimum="16pt" | |||
space-after.optimum="12pt"> | |||
The text/leader combination from table 1 without the table | |||
</fo:block> | |||
<fo:block text-align="start">What is FOP?<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block> | |||
<fo:block text-align="start">Downloading FOP<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block> | |||
<fo:block text-align="start">Running FOP<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block> | |||
<fo:block text-align="start">Embedding FOP<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block> | |||
<fo:block text-align="start">What is Implemented?<fo:leader leader-pattern="dots" | |||
leader-pattern-width="8pt" | |||
leader-alignment="reference-area" | |||
leader-length.maximum="14cm"/></fo:block> | |||
</fo:flow> | |||
</fo:page-sequence> | |||
</fo:root> |
@@ -753,8 +753,33 @@ | |||
<datatype>Length</datatype> | |||
</subproperty> | |||
</compound> | |||
<!-- <percent-ok base="CONTAINING-BOX"></percent-ok> | |||
<datatype-conversion type="Length" varname="lenval"> | |||
new LengthRange(lenval)</datatype-conversion> --> | |||
</property> | |||
<property> | |||
<name>leader-pattern-width</name> | |||
<class-name>LeaderPatternWidth</class-name> | |||
<inherited>true</inherited> | |||
<datatype>Length</datatype> | |||
<default contextdep="true">use-font-metrics</default> | |||
<keyword-equiv match="use-font-metrics" eval="true">0pt</keyword-equiv> | |||
<percent-ok base="CONTAINING-BOX"/> | |||
</property> | |||
<property> | |||
<name>leader-alignment</name> | |||
<inherited>true</inherited> | |||
<datatype>Enum</datatype> | |||
<enumeration> | |||
<value const="NONE">none</value> | |||
<value const="REFERENCE_AREA">reference-area</value> | |||
<value const="PAGE">page</value> | |||
</enumeration> | |||
<default>none</default> | |||
</property> | |||
<property> | |||
<name>scaling</name> | |||
<inherited>true</inherited> |
@@ -56,128 +56,113 @@ import org.apache.fop.fo.properties.*; | |||
import org.apache.fop.datatypes.*; | |||
import org.apache.fop.layout.Area; | |||
import org.apache.fop.layout.BlockArea; | |||
import org.apache.fop.layout.RuleArea; | |||
import org.apache.fop.layout.LeaderArea; | |||
import org.apache.fop.layout.FontState; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.messaging.MessageHandler; | |||
/** | |||
* This is just a basic implementation mostly based on the code of display-rule | |||
* It only supports the property leader-pattern="rule", nothing else, not even | |||
* leader-pattern="space" | |||
* | |||
* Implements fo:leader; main property of leader leader-pattern. | |||
* The following patterns are treated: rule, space, dots. | |||
* The pattern use-content is ignored, i.e. it still must be implemented. | |||
*/ | |||
public class Leader extends FObj { | |||
public class Leader extends FObjMixed { | |||
public static class Maker extends FObj.Maker { | |||
public FObj make(FObj parent, PropertyList propertyList) | |||
throws FOPException { | |||
return new Leader(parent, propertyList); | |||
} | |||
} | |||
public static FObj.Maker maker() { | |||
return new Leader.Maker(); | |||
} | |||
public Leader(FObj parent, PropertyList propertyList) { | |||
super(parent, propertyList); | |||
this.name = "fo:leader"; | |||
} | |||
public Status layout(Area area) throws FOPException { | |||
String fontFamily = this.properties.get("font-family").getString(); | |||
String fontStyle = this.properties.get("font-style").getString(); | |||
String fontWeight = this.properties.get("font-weight").getString(); | |||
int fontSize = this.properties.get("font-size").getLength().mvalue(); | |||
FontState fs = new FontState(area.getFontInfo(), fontFamily, | |||
fontStyle, fontWeight, fontSize); | |||
int align = this.properties.get("text-align").getEnum(); | |||
int startIndent = | |||
this.properties.get("start-indent").getLength().mvalue(); | |||
int endIndent = | |||
this.properties.get("end-indent").getLength().mvalue(); | |||
int spaceBefore = | |||
this.properties.get("space-before.optimum").getLength().mvalue(); | |||
int spaceAfter = | |||
this.properties.get("space-after.optimum").getLength().mvalue(); | |||
int ruleThickness = | |||
this.properties.get("rule-thickness").getLength().mvalue(); | |||
int ruleLength = this.properties.get("leader-length").getLength().mvalue(); | |||
int leaderPattern = this.properties.get("leader-pattern").getEnum(); | |||
ColorType c = this.properties.get("color").getColorType(); | |||
float red = c.red(); | |||
float green = c.green(); | |||
float blue = c.blue(); | |||
if (area instanceof BlockArea) { | |||
area.end(); | |||
} | |||
if (spaceBefore != 0) { | |||
area.addDisplaySpace(spaceBefore); | |||
public static class Maker extends FObj.Maker { | |||
public FObj make(FObj parent, | |||
PropertyList propertyList) throws FOPException { | |||
return new Leader(parent, propertyList); | |||
} | |||
} | |||
if (this.isInLabel) { | |||
startIndent += bodyIndent; | |||
endIndent += (area.getAllocationWidth() - | |||
distanceBetweenStarts - startIndent) + | |||
labelSeparation; | |||
public static FObj.Maker maker() { | |||
return new Leader.Maker(); | |||
} | |||
if (this.isInListBody) { | |||
startIndent += bodyIndent + distanceBetweenStarts; | |||
public Leader(FObj parent, PropertyList propertyList) { | |||
super(parent, propertyList); | |||
this.name = "fo:leader"; | |||
} | |||
if (this.isInTableCell) { | |||
startIndent += forcedStartOffset; | |||
endIndent += area.getAllocationWidth() - forcedWidth - | |||
forcedStartOffset; | |||
public Status layout(Area area) throws FOPException { | |||
BlockArea blockArea; | |||
//restriction in this version | |||
if (!(area instanceof BlockArea)) { | |||
MessageHandler.errorln("WARNING: in this version of Fop fo:leader must be a direct child of fo:block "); | |||
return new Status(Status.OK); | |||
} else { | |||
blockArea = (BlockArea) area; | |||
} | |||
//retrieving font property information for fo:leader | |||
String fontFamily = this.properties.get("font-family").getString(); | |||
String fontStyle = this.properties.get("font-style").getString(); | |||
String fontWeight = this.properties.get("font-weight").getString(); | |||
int fontSize = | |||
this.properties.get("font-size").getLength().mvalue(); | |||
//wrapping it up into Fontstate | |||
FontState fontstate = new FontState(area.getFontInfo(), fontFamily, | |||
fontStyle, fontWeight, fontSize); | |||
//color properties | |||
ColorType c = this.properties.get("color").getColorType(); | |||
float red = c.red(); | |||
float green = c.green(); | |||
float blue = c.blue(); | |||
//fo:leader specific properties | |||
//determines the pattern of leader; allowed values: space, rule,dots, use-content | |||
int leaderPattern = this.properties.get("leader-pattern").getEnum(); | |||
//length of the leader | |||
int leaderLengthOptimum = this.properties.get( | |||
"leader-length.optimum").getLength().mvalue(); | |||
int leaderLengthMinimum = this.properties.get( | |||
"leader-length.minimum").getLength().mvalue(); | |||
//brute force method to set default, because default values cannot be set | |||
//in the properties classes for all subtypes | |||
if (leaderLengthMinimum == 12000) { | |||
leaderLengthMinimum = 0; | |||
} | |||
int leaderLengthMaximum = this.properties.get( | |||
"leader-length.maximum").getLength().mvalue(); | |||
//here too | |||
if (leaderLengthMaximum == 12000) { | |||
leaderLengthMaximum = 24000; | |||
} | |||
//the following properties only apply for leader-pattern = "rule" | |||
int ruleThickness = this.properties.get( | |||
"rule-thickness").getLength().mvalue(); | |||
int ruleStyle = this.properties.get("rule-style").getEnum(); | |||
// if leaderPatternWidth = 0 = default = use-font-metric | |||
int leaderPatternWidth = this.properties.get( | |||
"leader-pattern-width").getLength().mvalue(); | |||
int leaderAlignment = | |||
this.properties.get("leader-alignment").getEnum(); | |||
// initialize id | |||
String id = this.properties.get("id").getString(); | |||
blockArea.getIDReferences().initializeID(id, blockArea); | |||
//adds leader to blockarea, there the leaderArea is generated | |||
int succeeded = blockArea.addLeader(fontstate, red, green, blue, | |||
leaderPattern, leaderLengthMinimum, | |||
leaderLengthOptimum, leaderLengthMaximum, | |||
ruleThickness, ruleStyle, leaderPatternWidth, | |||
leaderAlignment); | |||
if (succeeded == 1) { | |||
return new Status(Status.OK); | |||
} else { | |||
//not sure that this is the correct Status here | |||
return new Status(Status.AREA_FULL_SOME); | |||
} | |||
} | |||
// initialize id | |||
String id = this.properties.get("id").getString(); | |||
area.getIDReferences().initializeID(id,area); | |||
switch (leaderPattern) { | |||
case LeaderPattern.SPACE: | |||
ruleThickness = 0; | |||
MessageHandler.errorln("leader-pattern=\"space\" not supported by this version of Fop"); | |||
break; | |||
case LeaderPattern.RULE: | |||
break; | |||
case LeaderPattern.DOTS: | |||
MessageHandler.errorln("leader-pattern=\"dots\" not supported by this version of Fop"); | |||
break; | |||
case LeaderPattern.USECONTENT: | |||
MessageHandler.errorln("leader-pattern=\"use-content\" not supported by this version of Fop"); | |||
break; | |||
} | |||
RuleArea ruleArea = new RuleArea(fs, | |||
area.getAllocationWidth(), | |||
area.spaceLeft(), | |||
startIndent, endIndent, | |||
align, ruleThickness, | |||
ruleLength, red, green, | |||
blue); | |||
area.addChild(ruleArea); | |||
area.increaseHeight(ruleArea.getHeight()); | |||
if (spaceAfter != 0) { | |||
area.addDisplaySpace(spaceAfter); | |||
} | |||
/* //should only be necessary for use-content | |||
protected void addCharacters(char data[], int start, int length) { | |||
FOText textNode = new FOText(data,start,length, this); | |||
children.addElement(textNode); | |||
} | |||
*/ | |||
if (area instanceof BlockArea) { | |||
area.start(); | |||
} | |||
return new Status(Status.OK); | |||
} | |||
} |
@@ -56,6 +56,7 @@ import org.apache.fop.render.Renderer; | |||
// Java | |||
import java.util.Vector; | |||
import java.util.Enumeration; | |||
import org.apache.fop.messaging.MessageHandler; | |||
public class BlockArea extends Area { | |||
@@ -190,6 +191,78 @@ public class BlockArea extends Area { | |||
return -1; | |||
} | |||
/** | |||
* adds a leader to current line area of containing block area | |||
* the actual leader area is created in the line area | |||
* | |||
* @return int +1 for success and -1 for none | |||
*/ | |||
public int addLeader(FontState fontState, float red, float green, | |||
float blue, int leaderPattern, int leaderLengthMinimum, | |||
int leaderLengthOptimum, int leaderLengthMaximum, | |||
int ruleThickness, int ruleStyle, int leaderPatternWidth, | |||
int leaderAlignment) { | |||
//this should start a new page | |||
if (currentHeight + currentLineArea.getHeight() > maxHeight) { | |||
return -1; | |||
} | |||
this.currentLineArea.changeFont(fontState); | |||
this.currentLineArea.changeColor(red, green, blue); | |||
//check whether leader fits into the (rest of the) line | |||
//if leader is longer then create a new LineArea and put leader there | |||
if (leaderLengthMinimum <= (this.getContentWidth() - | |||
this.currentLineArea.finalWidth - | |||
this.currentLineArea.pendingWidth)) { | |||
this.currentLineArea.addLeader(leaderPattern, | |||
leaderLengthMinimum, leaderLengthOptimum, | |||
leaderLengthMaximum, ruleStyle, ruleThickness, | |||
leaderPatternWidth, leaderAlignment); | |||
} else { | |||
//finish current line area and put it into children vector | |||
this.currentLineArea.align(this.align); | |||
this.addLineArea(this.currentLineArea); | |||
//create new line area | |||
this.currentLineArea = | |||
new LineArea(fontState, lineHeight, halfLeading, | |||
allocationWidth, startIndent, endIndent, | |||
currentLineArea); | |||
this.currentLineArea.changeFont(fontState); | |||
this.currentLineArea.changeColor(red, green, blue); | |||
if (currentHeight + currentLineArea.getHeight() > | |||
this.maxHeight) { | |||
return -1; | |||
} | |||
//check whether leader fits into LineArea at all, otherwise | |||
//clip it (should honor the clip option of containing area) | |||
if (leaderLengthMinimum <= | |||
this.currentLineArea.getContentWidth()) { | |||
this.currentLineArea.addLeader(leaderPattern, | |||
leaderLengthMinimum, leaderLengthOptimum, | |||
leaderLengthMaximum, ruleStyle, ruleThickness, | |||
leaderPatternWidth, leaderAlignment); | |||
} else { | |||
MessageHandler.errorln("Leader doesn't fit into line, it will be clipped to fit."); | |||
this.currentLineArea.addLeader(leaderPattern, | |||
this.currentLineArea.getContentWidth() - | |||
this.currentLineArea.finalWidth - | |||
this.currentLineArea.pendingWidth, | |||
leaderLengthOptimum, leaderLengthMaximum, | |||
ruleStyle, ruleThickness, leaderPatternWidth, | |||
leaderAlignment); | |||
} | |||
} | |||
this.hasLines = true; | |||
return 1; | |||
} | |||
public void end() { | |||
if (this.hasLines) { | |||
this.currentLineArea.addPending(); |
@@ -54,11 +54,17 @@ import org.apache.fop.render.Renderer; | |||
public class InlineSpace extends Space { | |||
private int size; // in millipoints | |||
private boolean resizeable = true; //to disallow size changes during justification of a line | |||
public InlineSpace(int amount) { | |||
this.size = amount; | |||
} | |||
public InlineSpace(int amount, boolean resizeable) { | |||
this.resizeable = resizeable; | |||
this.size = amount; | |||
} | |||
public int getSize() { | |||
return size; | |||
} | |||
@@ -67,6 +73,14 @@ public class InlineSpace extends Space { | |||
this.size = amount; | |||
} | |||
public boolean getResizeable() { | |||
return resizeable; | |||
} | |||
public void setResizeable(boolean resizeable) { | |||
this.resizeable = resizeable; | |||
} | |||
public void render(Renderer renderer) { | |||
renderer.renderInlineSpace(this); | |||
} |
@@ -1,36 +1,36 @@ | |||
/*-- $Id$ -- | |||
/*-- $Id$ -- | |||
============================================================================ | |||
The Apache Software License, Version 1.1 | |||
============================================================================ | |||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||
Redistribution and use in source and binary forms, with or without modifica- | |||
tion, are permitted provided that the following conditions are met: | |||
1. Redistributions of source code must retain the above copyright notice, | |||
this list of conditions and the following disclaimer. | |||
2. Redistributions in binary form must reproduce the above copyright notice, | |||
this list of conditions and the following disclaimer in the documentation | |||
and/or other materials provided with the distribution. | |||
3. The end-user documentation included with the redistribution, if any, must | |||
include the following acknowledgment: "This product includes software | |||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||
Alternately, this acknowledgment may appear in the software itself, if | |||
and wherever such third-party acknowledgments normally appear. | |||
4. The names "Fop" and "Apache Software Foundation" must not be used to | |||
endorse or promote products derived from this software without prior | |||
written permission. For written permission, please contact | |||
apache@apache.org. | |||
5. Products derived from this software may not be called "Apache", nor may | |||
"Apache" appear in their name, without prior written permission of the | |||
Apache Software Foundation. | |||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||
@@ -41,12 +41,12 @@ | |||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
This software consists of voluntary contributions made by many individuals | |||
on behalf of the Apache Software Foundation and was originally created by | |||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||
Software Foundation, please see <http://www.apache.org/>. | |||
*/ | |||
package org.apache.fop.layout; | |||
@@ -55,55 +55,41 @@ import org.apache.fop.render.Renderer; | |||
import java.util.Vector; | |||
import java.util.Enumeration; | |||
public class RuleArea extends Area { | |||
int align; // text-align | |||
int length; // length in millipoints | |||
int ruleThickness; | |||
int startIndent; | |||
int endIndent; | |||
float red, green, blue; | |||
public RuleArea(FontState fontState, int allocationWidth, int maxHeight, int startIndent, int endIndent, int align, int ruleThickness, int length, float red, float green, float blue) { | |||
super(fontState,allocationWidth,maxHeight); | |||
this.contentRectangleWidth = allocationWidth - startIndent - endIndent; | |||
this.align = align; | |||
this.startIndent = startIndent; | |||
this.endIndent = endIndent; | |||
this.ruleThickness = ruleThickness; | |||
this.length = length; | |||
this.currentHeight = maxHeight; | |||
this.red = red; | |||
this.green = green; | |||
this.blue = blue; | |||
} | |||
public class LeaderArea extends InlineArea { | |||
int ruleThickness; | |||
int leaderLengthOptimum; | |||
int leaderPattern; | |||
int ruleStyle; | |||
float red, green, blue; | |||
public LeaderArea(FontState fontState, float red, float green, | |||
float blue, String text, int leaderLengthOptimum, | |||
int leaderPattern, int ruleThickness, int ruleStyle) { | |||
super(fontState, red, green, blue, text, leaderLengthOptimum); | |||
this.ruleThickness = ruleThickness; | |||
this.leaderPattern = leaderPattern; | |||
this.leaderLengthOptimum = leaderLengthOptimum; | |||
this.ruleStyle = ruleStyle; | |||
} | |||
public void render(Renderer renderer) { | |||
renderer.renderRuleArea(this); | |||
renderer.renderLeaderArea(this); | |||
} | |||
public int getRuleThickness() { | |||
return this.ruleThickness; | |||
} | |||
public int getRuleStyle() { | |||
return this.ruleStyle; | |||
} | |||
public float getBlue() { | |||
return this.blue; | |||
} | |||
public int getEndIndent() { | |||
return endIndent; | |||
} | |||
public float getGreen() { | |||
return this.green; | |||
} | |||
public int getHeight() { | |||
return this.ruleThickness; | |||
} | |||
public float getRed() { | |||
return this.red; | |||
} | |||
public int getRuleThickness() { | |||
return this.ruleThickness; | |||
} | |||
public int getStartIndent() { | |||
return startIndent; | |||
} | |||
public int getLeaderPattern() { | |||
return this.leaderPattern; | |||
} | |||
public int getLeaderLength() { | |||
return this.contentRectangleWidth; | |||
} | |||
} |
@@ -53,6 +53,7 @@ package org.apache.fop.layout; | |||
import org.apache.fop.render.Renderer; | |||
import org.apache.fop.messaging.MessageHandler; | |||
import org.apache.fop.layout.LeaderArea; | |||
import java.util.Vector; | |||
import java.util.Enumeration; | |||
@@ -66,6 +67,8 @@ import org.apache.fop.fo.properties.TextAlign; // for enumerated | |||
// values | |||
import org.apache.fop.fo.properties.TextAlignLast; // for enumerated | |||
// values | |||
import org.apache.fop.fo.properties.LeaderPattern; | |||
import org.apache.fop.fo.properties.LeaderAlignment; | |||
import org.apache.fop.datatypes.IDNode; | |||
@@ -179,6 +182,11 @@ public class LineArea extends Area { | |||
} | |||
/** | |||
* adds text to line area | |||
* | |||
* @return int character position | |||
*/ | |||
public int addText(char odata[], int start, int end, LinkSet ls, | |||
boolean ul) { | |||
boolean overrun = false; | |||
@@ -248,17 +256,19 @@ public class LineArea extends Area { | |||
Enumeration e = pendingAreas.elements(); | |||
while (e.hasMoreElements()) { | |||
InlineArea inlineArea = | |||
(InlineArea) e.nextElement(); | |||
if (ls != null) { | |||
Rectangle lr = new Rectangle(finalWidth, 0, | |||
inlineArea.getContentWidth(), | |||
fontState.getFontSize()); | |||
ls.addRect(lr, this); | |||
Box box = (Box) e.nextElement(); | |||
if (box instanceof InlineArea) { | |||
if (ls != null) { | |||
Rectangle lr = new Rectangle(finalWidth, 0, | |||
((InlineArea) box). | |||
getContentWidth(), | |||
fontState.getFontSize()); | |||
ls.addRect(lr, this); | |||
} | |||
} | |||
addChild(inlineArea); | |||
addChild(box); | |||
} | |||
finalWidth += pendingWidth; | |||
// reset pending areas array | |||
@@ -300,9 +310,9 @@ public class LineArea extends Area { | |||
if (this.spaceTreatment == | |||
SpaceTreatment.IGNORE) { | |||
// do nothing | |||
} else { | |||
} else { | |||
spaceWidth = currentFontState.width(32); | |||
} | |||
} | |||
*/ | |||
@@ -406,6 +416,113 @@ public class LineArea extends Area { | |||
return -1; | |||
} | |||
/** | |||
* adds a Leader; actually the method receives the leader properties | |||
* and creates a leader area or an inline area which is appended to | |||
* the children of the containing line area. <br> | |||
* leader pattern use-content is not implemented. | |||
*/ | |||
public void addLeader(int leaderPattern, int leaderLengthMinimum, | |||
int leaderLengthOptimum, int leaderLengthMaximum, | |||
int ruleStyle, int ruleThickness, int leaderPatternWidth, | |||
int leaderAlignment) { | |||
InlineArea leaderPatternArea; | |||
int leaderLength; | |||
int remainingWidth = this.getContentWidth() - this.getCurrentXPosition(); | |||
//here is the point to decide which leader-length is to be used, either | |||
//optimum or maximum. At the moment maximum is used if the remaining | |||
//width isn't smaller. In this case only the remaining width is used for | |||
//the leader. Actually this means, optimum is never used at the moment. | |||
if (remainingWidth < leaderLengthMaximum) { | |||
leaderLength = remainingWidth; | |||
} else { | |||
leaderLength = leaderLengthMaximum; | |||
} | |||
switch (leaderPattern) { | |||
case LeaderPattern.SPACE: | |||
//whitespace setting must be false for this | |||
int whiteSpaceSetting = this.whiteSpaceCollapse; | |||
this.changeWhiteSpaceCollapse(WhiteSpaceCollapse.FALSE); | |||
pendingAreas.addElement(this.buildSimpleLeader(32,leaderLength)); | |||
this.changeWhiteSpaceCollapse(whiteSpaceSetting); | |||
break; | |||
case LeaderPattern.RULE: | |||
LeaderArea leaderArea = | |||
new LeaderArea(fontState, red, green, blue, "", | |||
leaderLength, leaderPattern, ruleThickness, | |||
ruleStyle); | |||
pendingAreas.addElement(leaderArea); | |||
break; | |||
case LeaderPattern.DOTS: | |||
//if the width of a dot is larger than leader-pattern-width | |||
//ignore this property | |||
if (leaderPatternWidth < this.currentFontState.width(46)) { | |||
leaderPatternWidth = 0; | |||
} | |||
//if value of leader-pattern-width is 'use-font-metrics' (0) | |||
if (leaderPatternWidth == 0) { | |||
pendingAreas.addElement(this.buildSimpleLeader(46,leaderLength)); | |||
} else { | |||
//if leader-alignment is used, calculate space to insert before leader | |||
//so that all dots will be parallel. | |||
if (leaderAlignment == LeaderAlignment.REFERENCE_AREA) { | |||
int spaceBeforeLeader = | |||
this.getLeaderAlignIndent(leaderLength, | |||
leaderPatternWidth); | |||
//appending indent space leader-alignment | |||
//setting InlineSpace to false, so it is not used in line justification | |||
if (spaceBeforeLeader != 0) { | |||
pendingAreas.addElement( | |||
new InlineSpace(spaceBeforeLeader,false)); | |||
pendingWidth += spaceBeforeLeader; | |||
//shorten leaderLength, otherwise - in case of | |||
//leaderLength=remaining length - it will cut off the end of | |||
//leaderlength | |||
leaderLength -= spaceBeforeLeader; | |||
} | |||
} | |||
// calculate the space to insert between the dots and create a | |||
//inline area with this width | |||
InlineSpace spaceBetweenDots = | |||
new InlineSpace(leaderPatternWidth - | |||
this.currentFontState.width(46),false); | |||
leaderPatternArea = new InlineArea(currentFontState, this.red, | |||
this.green, this.blue, new String ("."), | |||
this.currentFontState.width(46)); | |||
int dotsFactor = (int) Math.floor (((double) leaderLength )/ | |||
((double)leaderPatternWidth)); | |||
//add combination of dot + space to fill leader | |||
//is there a way to do this in a more effective way? | |||
for (int i = 0; i < dotsFactor; i++) { | |||
pendingAreas.addElement(leaderPatternArea); | |||
pendingAreas.addElement(spaceBetweenDots); | |||
} | |||
//append at the end some space to fill up to leader length | |||
pendingAreas.addElement( new InlineSpace(leaderLength - | |||
dotsFactor * leaderPatternWidth)); | |||
} | |||
break; | |||
//leader pattern use-content not implemented. | |||
case LeaderPattern.USECONTENT: | |||
MessageHandler.errorln("leader-pattern=\"use-content\" not " | |||
+ "supported by this version of Fop"); | |||
return; | |||
} | |||
//adds leader length to length of pending inline areas | |||
pendingWidth += leaderLength; | |||
//sets prev to TEXT and makes so sure, that also blocks only | |||
//containing leaders are processed | |||
prev = TEXT; | |||
} | |||
/** | |||
* adds pending inline areas to the line area | |||
* normally done,if the line area is filled and | |||
* added as child to the parent block area | |||
*/ | |||
public void addPending() { | |||
if (spaceWidth > 0) { | |||
addChild(new InlineSpace(spaceWidth)); | |||
@@ -415,9 +532,10 @@ public class LineArea extends Area { | |||
Enumeration e = pendingAreas.elements(); | |||
while (e.hasMoreElements()) { | |||
InlineArea inlineArea = (InlineArea) e.nextElement(); | |||
addChild(inlineArea); | |||
Box box = (Box) e.nextElement(); | |||
addChild(box); | |||
} | |||
finalWidth += pendingWidth; | |||
// reset pending areas array | |||
@@ -425,6 +543,10 @@ public class LineArea extends Area { | |||
pendingAreas = new Vector(); | |||
} | |||
/** | |||
* aligns line area | |||
* | |||
*/ | |||
public void align(int type) { | |||
int padding = 0; | |||
@@ -451,8 +573,10 @@ public class LineArea extends Area { | |||
Box b = (Box) e.nextElement(); | |||
if (b instanceof InlineSpace) { | |||
InlineSpace space = (InlineSpace) b; | |||
spaceList.addElement(space); | |||
spaceCount++; | |||
if (space.getResizeable()) { | |||
spaceList.addElement(space); | |||
spaceCount++; | |||
} | |||
} | |||
} | |||
if (spaceCount > 0) { | |||
@@ -524,4 +648,51 @@ public class LineArea extends Area { | |||
pendingWidth = width; | |||
} | |||
/** | |||
* creates a leader as String out of the given char and the leader length | |||
* and wraps it in an InlineArea which is returned | |||
*/ | |||
private InlineArea buildSimpleLeader(int charNumber,int leaderLength) { | |||
int factor = (int) Math.floor (leaderLength / | |||
this.currentFontState.width(charNumber)); | |||
char [] leaderChars = new char [factor]; | |||
char fillChar = (char) charNumber; | |||
for (int i = 0; i < factor; i ++) { | |||
leaderChars[i] = fillChar; | |||
} | |||
InlineArea leaderPatternArea = new InlineArea(currentFontState, this.red, | |||
this.green, this.blue, new String (leaderChars), | |||
leaderLength); | |||
return leaderPatternArea; | |||
} | |||
/** | |||
* calculates the width of space which has to be inserted before the | |||
* start of the leader, so that all leader characters are aligned. | |||
* is used if property leader-align is set. At the moment only the value | |||
* for leader-align="reference-area" is supported. | |||
* | |||
*/ | |||
private int getLeaderAlignIndent (int leaderLength, | |||
int leaderPatternWidth ) { | |||
//calculate position of used space in line area | |||
double position = getCurrentXPosition(); | |||
//calculate factor of next leader pattern cycle | |||
double nextRepeatedLeaderPatternCycle = | |||
Math.ceil(position / leaderPatternWidth); | |||
//calculate difference between start of next leader | |||
//pattern cycle and already used space | |||
double difference = (leaderPatternWidth * | |||
nextRepeatedLeaderPatternCycle) - position; | |||
return (int) difference; | |||
} | |||
/** | |||
* calculates the used space in this line area | |||
*/ | |||
private int getCurrentXPosition() { | |||
return finalWidth + spaceWidth + startIndent + pendingWidth; | |||
} | |||
} |
@@ -107,6 +107,7 @@ public interface Renderer { | |||
/** render the given page */ | |||
public void renderPage(Page page); | |||
/** render the given rule area */ | |||
public void renderRuleArea(RuleArea area); | |||
/** render the given leader area */ | |||
public void renderLeaderArea(LeaderArea area); | |||
} |
@@ -613,29 +613,31 @@ public class AWTRenderer implements Renderer, Printable, Pageable { | |||
this.currentYPosition = ry - h; | |||
} | |||
/** | |||
* render rule area into PDF | |||
* | |||
* @param area area to render | |||
*/ | |||
public void renderRuleArea(RuleArea area) { | |||
int rx = this.currentAreaContainerXPosition + area.getStartIndent(); | |||
int ry = this.currentYPosition; | |||
int w = area.getContentWidth(); | |||
int h = area.getHeight(); | |||
int th = area.getRuleThickness(); | |||
float r = area.getRed(); | |||
float g = area.getGreen(); | |||
float b = area.getBlue(); | |||
Color oldColor = graphics.getColor(); | |||
/** | |||
* render leader area into AWT | |||
* | |||
* @param area area to render | |||
*/ | |||
public void renderLeaderArea(LeaderArea area) { | |||
int rx = this.currentXPosition; | |||
int ry = this.currentYPosition; | |||
int w = area.getLeaderLength(); | |||
int h = area.getHeight(); | |||
int th = area.getRuleThickness(); | |||
int st = area.getRuleStyle(); //not used at the moment | |||
float r = area.getRed(); | |||
float g = area.getGreen(); | |||
float b = area.getBlue(); | |||
Color oldColor = graphics.getColor(); | |||
graphics.setColor(new Color(r, g, b)); | |||
graphics.fillRect((int)(rx / 1000f), (int)(pageHeight - ry / 1000f), | |||
(int)(w / 1000f), (int)(th / 1000f)); | |||
graphics.setColor(oldColor); | |||
this.currentXPosition += area.getContentWidth(); | |||
} | |||
graphics.setColor(new Color(r, g, b)); | |||
graphics.fillRect((int)(rx / 1000f), | |||
(int)(pageHeight - ry / 1000f), (int)(w / 1000f), | |||
(int)(th / 1000f)); | |||
graphics.setColor(oldColor); | |||
} | |||
public void renderSVGArea(SVGArea area) { | |||
@@ -665,19 +665,20 @@ public class PDFRenderer implements Renderer { | |||
} | |||
/** | |||
* render rule area into PDF | |||
* render leader area into PDF | |||
* | |||
* @param area area to render | |||
*/ | |||
public void renderRuleArea(RuleArea area) { | |||
int rx = this.currentAreaContainerXPosition | |||
+ area.getStartIndent(); | |||
public void renderLeaderArea(LeaderArea area) { | |||
int rx = this.currentXPosition;; | |||
int ry = this.currentYPosition; | |||
int w = area.getContentWidth(); | |||
int h = area.getHeight(); | |||
int th = area.getRuleThickness(); | |||
int st = area.getRuleStyle(); //not used at the moment | |||
addLine(rx, ry, rx+w, ry, th, new PDFColor(area.getRed(), area.getGreen(),area.getBlue())); | |||
this.currentXPosition += area.getContentWidth(); | |||
} | |||
/** |
@@ -59,6 +59,7 @@ import org.apache.fop.render.Renderer; | |||
import org.apache.fop.image.ImageArea; | |||
import org.apache.fop.layout.*; | |||
import org.apache.fop.pdf.*; | |||
import org.apache.fop.fo.properties.LeaderPattern; | |||
// Java | |||
import java.io.IOException; | |||
@@ -317,20 +318,32 @@ public class XMLRenderer implements Renderer { | |||
} | |||
/** | |||
* render a rule area to XML | |||
* | |||
* @param area the area to render | |||
*/ | |||
public void renderRuleArea(RuleArea area) { | |||
writeEmptyElementTag("<Rule start-indent=\"" | |||
+ area.getStartIndent() | |||
+ "\" end-indent=\"" | |||
+ area.getEndIndent() | |||
+ "\" rule-thickness=\"" | |||
+ area.getRuleThickness() | |||
+ "\" red=\"" + area.getRed() | |||
+ "\" green=\"" + area.getGreen() | |||
+ "\" blue = \"" + area.getBlue() | |||
+ "\"/>"); | |||
* render a leader area to XML | |||
* | |||
* @param area the area to render | |||
*/ | |||
public void renderLeaderArea(LeaderArea area) { | |||
String leaderPattern = ""; | |||
switch (area.getLeaderPattern()) { | |||
case LeaderPattern.SPACE: | |||
leaderPattern = "space"; | |||
break; | |||
case LeaderPattern.RULE: | |||
leaderPattern = "rule"; | |||
break; | |||
case LeaderPattern.DOTS: | |||
leaderPattern = "dots"; | |||
break; | |||
case LeaderPattern.USECONTENT: | |||
leaderPattern = "use-content"; | |||
break; | |||
} | |||
writeEmptyElementTag("<Leader leader-pattern=\"" + leaderPattern + | |||
" leader-length=\"" + area.getLeaderLength()+ | |||
"\" rule-thickness=\"" + area.getRuleThickness() + | |||
"\" rule-style=\"" + area.getRuleStyle() + | |||
"\" red=\"" + area.getRed() + "\" green=\"" + area.getGreen() + | |||
"\" blue = \"" + area.getBlue() + "\"/>"); | |||
} | |||
} |