summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJordan Naftolin <jordan@apache.org>2000-07-05 23:06:58 +0000
committerJordan Naftolin <jordan@apache.org>2000-07-05 23:06:58 +0000
commitf7e34078275baa7d0845bc76374fda4a5097c672 (patch)
tree93197154fe9bba37ef4b00310c068072fd1956f7 /src
parentab19f336d7ff76b0d1e75ea8fda7e70ddadbe3ff (diff)
downloadxmlgraphics-fop-f7e34078275baa7d0845bc76374fda4a5097c672.tar.gz
xmlgraphics-fop-f7e34078275baa7d0845bc76374fda4a5097c672.zip
Added basic support for forward page-number-citations
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193455 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/org/apache/fop/datatypes/IDNode.java2
-rw-r--r--src/org/apache/fop/datatypes/IDReferences.java3
-rw-r--r--src/org/apache/fop/fo/flow/PageNumberCitation.java13
-rw-r--r--src/org/apache/fop/layout/BlockArea.java22
-rw-r--r--src/org/apache/fop/layout/InlineArea.java5
-rw-r--r--src/org/apache/fop/layout/LineArea.java25
-rw-r--r--src/org/apache/fop/render/pdf/PDFRenderer.java16
7 files changed, 78 insertions, 8 deletions
diff --git a/src/org/apache/fop/datatypes/IDNode.java b/src/org/apache/fop/datatypes/IDNode.java
index 2645566a4..0ef57e895 100644
--- a/src/org/apache/fop/datatypes/IDNode.java
+++ b/src/org/apache/fop/datatypes/IDNode.java
@@ -96,7 +96,7 @@ public class IDNode
*
* @return page number of this node
*/
- protected String getPageNumber()
+ public String getPageNumber()
{
return(pageNumber != -1)?new Integer(pageNumber).toString():null;
}
diff --git a/src/org/apache/fop/datatypes/IDReferences.java b/src/org/apache/fop/datatypes/IDReferences.java
index ef511f5c6..083c10adb 100644
--- a/src/org/apache/fop/datatypes/IDReferences.java
+++ b/src/org/apache/fop/datatypes/IDReferences.java
@@ -52,6 +52,7 @@
package org.apache.fop.datatypes;
import org.apache.fop.pdf.PDFGoTo;
+import org.apache.fop.layout.AreaContainer;
// Java
@@ -125,7 +126,7 @@ public class IDReferences {
public void configureID(String id, Area area)
{
if ( id!=null && !id.equals("") ) {
- setPosition(id,area.getPage().getBody().getXPosition()-ID_PADDING,area.getPage().getBody().getYPosition() - area.getAbsoluteHeight()+ID_PADDING);
+ setPosition(id,area.getPage().getBody().getXPosition()+area.getTableCellXOffset()-ID_PADDING,area.getPage().getBody().getYPosition() - area.getAbsoluteHeight()+ID_PADDING);
setPageNumber(id,area.getPage().getNumber());
area.getPage().addToIDList(id);
}
diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java
index d9faf67c3..a5b8be56f 100644
--- a/src/org/apache/fop/fo/flow/PageNumberCitation.java
+++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java
@@ -186,12 +186,19 @@ public class PageNumberCitation extends FObj
IDReferences idReferences= area.getIDReferences();
String pageNumber=idReferences.getPageNumber(refId);
- String output = (pageNumber!=null)?pageNumber:"?";
-
int orig_start = this.marker;
- this.marker = ((BlockArea) area).addText(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, output.toCharArray(), 0, output.length());
+ if(pageNumber!=null) // if we already know the page number
+ {
+ String output=pageNumber;
+ this.marker = ((BlockArea) area).addText(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, output.toCharArray(), 0, output.length());
+ }
+ else // add pageNumberCitation to area to be resolved during rendering
+ {
+ this.marker = ((BlockArea) area).addPageNumberCitation(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, refId);
+ }
+
if ( this.marker == -1 )
{
diff --git a/src/org/apache/fop/layout/BlockArea.java b/src/org/apache/fop/layout/BlockArea.java
index 4831b0fea..3cb5a7772 100644
--- a/src/org/apache/fop/layout/BlockArea.java
+++ b/src/org/apache/fop/layout/BlockArea.java
@@ -115,6 +115,28 @@ public class BlockArea extends Area {
}
}
+ public int addPageNumberCitation(FontState fontState, float red, float green,
+ float blue, int wrapOption, LinkSet ls,
+ int whiteSpaceTreatment, String refid) {
+
+ this.currentLineArea.changeFont(fontState);
+ this.currentLineArea.changeColor(red, green, blue);
+ this.currentLineArea.changeWrapOption(wrapOption);
+ this.currentLineArea.changeWhiteSpaceTreatment(whiteSpaceTreatment);
+
+ if (ls != null) {
+ this.currentLinkSet = ls;
+ ls.setYOffset(currentHeight);
+ }
+
+ this.currentLineArea.addPageNumberCitation(refid,ls);
+ this.hasLines = true;
+
+ return -1;
+
+ }
+
+Imaginary Buffer Line
public int addText(FontState fontState, float red, float green,
float blue, int wrapOption, LinkSet ls,
int whiteSpaceTreatment, char data[],
diff --git a/src/org/apache/fop/layout/InlineArea.java b/src/org/apache/fop/layout/InlineArea.java
index 239270a7a..f55c6b9fc 100644
--- a/src/org/apache/fop/layout/InlineArea.java
+++ b/src/org/apache/fop/layout/InlineArea.java
@@ -55,6 +55,7 @@ import org.apache.fop.render.Renderer;
public class InlineArea extends Area {
private String text;
+ protected String pageNumberId=null;
private float red, green, blue;
public InlineArea(FontState fontState, float red, float green, float blue, String text, int width) {
@@ -85,4 +86,8 @@ public class InlineArea extends Area {
public String getText() {
return this.text;
}
+
+ public String getPageNumberID() {
+ return pageNumberId;
+ }
}
diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java
index edfbee2d1..182cf62c8 100644
--- a/src/org/apache/fop/layout/LineArea.java
+++ b/src/org/apache/fop/layout/LineArea.java
@@ -67,6 +67,8 @@ import org.apache.fop.fo.properties.TextAlign; // for enumerated
import org.apache.fop.fo.properties.TextAlignLast; // for enumerated
// values
+import org.apache.fop.datatypes.IDNode;
+
public class LineArea extends Area {
protected int lineHeight;
@@ -149,6 +151,29 @@ public class LineArea extends Area {
renderer.renderLineArea(this);
}
+ public int addPageNumberCitation(String refid, LinkSet ls)
+ {
+
+ /* We should add code here to handle the case where the page number doesn't fit on the current line
+ */
+
+ //Space must be alloted to the page number, so currently we give it 3 spaces
+ int width= currentFontState.width(32) * 3;
+
+ PageNumberInlineArea pia = new PageNumberInlineArea(currentFontState,
+ this.red, this.green,
+ this.blue,
+ refid,
+ width);
+
+ pendingAreas.addElement(pia);
+ pendingWidth += width;
+ wordWidth = 0;
+
+ return -1;
+ }
+
+
public int addText(char odata[], int start, int end, LinkSet ls) {
boolean overrun = false;
diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java
index db68fe764..0fe1609a7 100644
--- a/src/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/org/apache/fop/render/pdf/PDFRenderer.java
@@ -74,13 +74,16 @@ import java.util.Vector;
* Renderer that renders areas to PDF
*/
public class PDFRenderer implements Renderer {
-
+
/** the PDF Document being created */
protected PDFDocument pdfDoc;
/** the /Resources object of the PDF document being created */
protected PDFResources pdfResources;
+ /** the IDReferences for this document */
+ protected IDReferences idReferences;
+
/** the current stream to add PDF commands to */
PDFStream currentStream;
@@ -145,7 +148,7 @@ public class PDFRenderer implements Renderer {
public void render(AreaTree areaTree, PrintWriter writer)
throws IOException, FOPException {
MessageHandler.logln("rendering areas to PDF");
- IDReferences idReferences=areaTree.getIDReferences();
+ idReferences=areaTree.getIDReferences();
this.pdfResources = this.pdfDoc.getResources();
this.pdfDoc.setIDReferences(idReferences);
Enumeration e = areaTree.getPages().elements();
@@ -431,7 +434,14 @@ public class PDFRenderer implements Renderer {
+(rx/1000f) + " " + (bl/1000f)
+ " Tm (");
- String s = area.getText();
+ String s;
+ if ( area.getPageNumberID()!=null ) { // this text is a page number, so resolve it
+ s = idReferences.getPageNumber(area.getPageNumberID());
+ }
+ else {
+ s = area.getText();
+ }
+
int l = s.length();
for (int i=0; i < l; i++) {