aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-04-23 09:31:08 +0000
committerJeremias Maerki <jeremias@apache.org>2006-04-23 09:31:08 +0000
commitfcfb10d2ec7797f769ff911e64aaade9de2faf1e (patch)
tree840a06ad0c1927fbd08edb346593a2b30cfdbb70 /src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
parent0fa858c3b16c8cdfe0cbc83b1981f454070ef994 (diff)
downloadxmlgraphics-fop-fcfb10d2ec7797f769ff911e64aaade9de2faf1e.tar.gz
xmlgraphics-fop-fcfb10d2ec7797f769ff911e64aaade9de2faf1e.zip
Bugzilla #39118:
Initial support for page-number-citation-last (XSL 1.1). Works without problems only for page-sequence so far. Submitted by: Pierre-Henri Kraus <phkraus.at.skynet.be> Modifications to the patch by jeremias during review: - Tab character removed - Some style fixes and javadoc enhancements - Renamed some methods in AreaTreeHandler to some more speaking names - Changed the ..._basic.xml testcase so it shows a remaining problem: Forward references are not properly resolved, yet. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@396243 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java')
-rw-r--r--src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
index 99978e7c6..fc28bda49 100644
--- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
+++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,20 +34,39 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable {
private boolean resolved = false;
private String pageIDRef;
private String text;
+ private boolean pageType;
+ /** Indicates that the reference refers to the first area generated by a formatting object. */
+ public static final boolean FIRST = true;
+ /** Indicates that the reference refers to the last area generated by a formatting object. */
+ public static final boolean LAST = false;
+
//Transient fields
private transient Font font;
/**
- * Create a new unresolvable page number.
+ * Create a new unresolved page number.
*
* @param id the id reference for resolving this
* @param f the font for formatting the page number
*/
public UnresolvedPageNumber(String id, Font f) {
+ this(id, f, FIRST);
+ }
+
+ /**
+ * Create a new unresolved page number.
+ *
+ * @param id the id reference for resolving this
+ * @param f the font for formatting the page number
+ * @param type indicates whether the reference refers to the first or last area generated by
+ * a formatting object
+ */
+ public UnresolvedPageNumber(String id, Font f, boolean type) {
pageIDRef = id;
font = f;
text = "?";
+ pageType = type;
}
/**
@@ -70,9 +89,17 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable {
* @param pages the list of PageViewports associated with this ID
*/
public void resolveIDRef(String id, List pages) {
+ if (log.isDebugEnabled()) {
+ log.debug("Resolving pageNumber: " + id);
+ }
if (pageIDRef.equals(id) && pages != null) {
resolved = true;
- PageViewport page = (PageViewport)pages.get(0);
+ PageViewport page;
+ if (pageType == FIRST) {
+ page = (PageViewport)pages.get(0);
+ } else {
+ page = (PageViewport)pages.get(pages.size() - 1);
+ }
// replace the text
removeText();
addWord(page.getPageNumberString(), 0);
@@ -83,7 +110,7 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable {
font = null;
} else {
log.warn("Cannot update the IPD of an unresolved page number."
- + " No font information avilable.");
+ + " No font information available.");
}
}
}
@@ -108,5 +135,4 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable {
int lineStretch, int lineShrink) {
return true;
}
-
}