package org.apache.fop.fo.flow;
+// Java
+import java.util.List;
+
// XML
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
// FOP
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.FONode;
-import org.apache.fop.layoutmgr.AddLMVisitor;
import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.properties.CommonAccessibility;
-import org.apache.fop.fo.properties.CommonAural;
-import org.apache.fop.fo.properties.CommonBackground;
-import org.apache.fop.fo.properties.CommonBorderAndPadding;
-import org.apache.fop.fo.properties.CommonMarginInline;
-import org.apache.fop.fo.properties.CommonRelativePosition;
import org.apache.fop.fonts.Font;
-import org.apache.fop.fo.LMVisited;
-
+import org.apache.fop.layoutmgr.PageNumberLayoutManager;
/**
* Class modelling the fo:page-number object. See Sec. 6.6.10 of the XSL-FO
* Standard.
*/
-public class PageNumber extends FObj implements LMVisited {
+public class PageNumber extends FObj {
/** FontState for this object */
protected Font fontState;
}
private void setup() {
-
- // Common Accessibility Properties
- CommonAccessibility mAccProps = propMgr.getAccessibilityProps();
-
- // Common Aural Properties
- CommonAural mAurProps = propMgr.getAuralProps();
-
- // Common Border, Padding, and Background Properties
- CommonBorderAndPadding bap = propMgr.getBorderAndPadding();
- CommonBackground bProps = propMgr.getBackgroundProps();
-
// Common Font Properties
this.fontState = propMgr.getFontState(getFOInputHandler().getFontInfo());
- // Common Margin Properties-Inline
- CommonMarginInline mProps = propMgr.getMarginInlineProps();
-
- // Common Relative Position Properties
- CommonRelativePosition mRelProps =
- propMgr.getRelativePositionProps();
-
- // this.propertyList.get("alignment-adjust");
- // this.propertyList.get("alignment-baseline");
- // this.propertyList.get("baseline-shift");
- // this.propertyList.get("dominant-baseline");
setupID();
- // this.propertyList.get("keep-with-next");
- // this.propertyList.get("keep-with-previous");
- // this.propertyList.get("letter-spacing");
- // this.propertyList.get("line-height");
- // this.propertyList.get("line-height-shift-adjustment");
- // this.propertyList.get("score-spaces");
- // this.propertyList.get("text-decoration");
- // this.propertyList.get("text-shadow");
- // this.propertyList.get("text-transform");
- // this.propertyList.get("word-spacing");
ColorType c = this.propertyList.get(PR_COLOR).getColorType();
this.red = c.getRed();
this.blue = c.getBlue();
this.wrapOption = this.propertyList.get(PR_WRAP_OPTION).getEnum();
-
}
/**
getFOInputHandler().endPageNumber(this);
}
- public String getName() {
- return "fo:page-number";
- }
-
/**
- * This is a hook for the AddLMVisitor class to be able to access
- * this object.
- * @param aLMV the AddLMVisitor object that can access this object.
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
- public void acceptVisitor(AddLMVisitor aLMV) {
- setup();
- aLMV.servePageNumber(this);
+ public void addLayoutManager(List list) {
+ PageNumberLayoutManager lm = new PageNumberLayoutManager(this);
+ list.add(lm);
+ }
+
+ public String getName() {
+ return "fo:page-number";
}
}
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.InlineParent;
import org.apache.fop.area.inline.Space;
-import org.apache.fop.area.inline.UnresolvedPageNumber;
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.InstreamForeignObject;
import org.apache.fop.fo.flow.Leader;
-import org.apache.fop.fo.flow.PageNumber;
import org.apache.fop.fo.flow.RetrieveMarker;
import org.apache.fop.fo.flow.Table;
import org.apache.fop.fo.flow.TableAndCaption;
return areaCurrent;
}
- /**
- * Overridden from FObj
- * @param lms the list to which the layout manager(s) should be added
- */
- public void servePageNumber(final PageNumber node) {
- LayoutManager lm;
- lm = new LeafNodeLayoutManager(node) {
- public InlineArea get(LayoutContext context) {
- // get page string from parent, build area
- TextArea inline = new TextArea();
- String str = parentLM.getCurrentPageNumber();
- int width = 0;
- for (int count = 0; count < str.length(); count++) {
- width += node.getFontState().getCharWidth(
- str.charAt(count));
- }
- inline.setTextArea(str);
- inline.setIPD(width);
- inline.setHeight(node.getFontState().getAscender()
- - node.getFontState().getDescender());
- inline.setOffset(node.getFontState().getAscender());
-
- inline.addTrait(Trait.FONT_NAME,
- node.getFontState().getFontName());
- inline.addTrait(Trait.FONT_SIZE,
- new Integer(node.getFontState().getFontSize()));
-
- return inline;
- }
-
- protected void offsetArea(LayoutContext context) {
- curArea.setOffset(context.getBaseline());
- }
- };
- currentLMList.add(lm);
- }
-
public void serveTable(Table node) {
TableLayoutManager tlm = new TableLayoutManager(node);
ArrayList columns = node.getColumns();
--- /dev/null
+/*
+ * Copyright 1999-2004 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr;
+
+import org.apache.fop.fo.flow.PageNumber;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.Trait;
+import org.apache.fop.fonts.Font;
+
+/**
+ * LayoutManager for the fo:basic-link formatting object
+ */
+public class PageNumberLayoutManager extends LeafNodeLayoutManager {
+
+ Font font = null;
+
+ /**
+ * Constructor
+ *
+ * @param node the fo:page-number formatting object that creates the area
+ * @todo better null checking of node, font
+ */
+ public PageNumberLayoutManager(PageNumber node) {
+ super(node);
+ font = node.getFontState();
+ }
+
+ public InlineArea get(LayoutContext context) {
+ // get page string from parent, build area
+ TextArea inline = new TextArea();
+ String str = parentLM.getCurrentPageNumber();
+ int width = 0;
+ for (int count = 0; count < str.length(); count++) {
+ width += font.getCharWidth(str.charAt(count));
+ }
+ inline.setTextArea(str);
+ inline.setIPD(width);
+ inline.setHeight(font.getAscender() - font.getDescender());
+ inline.setOffset(font.getAscender());
+ inline.addTrait(Trait.FONT_NAME, font.getFontName());
+ inline.addTrait(Trait.FONT_SIZE,
+ new Integer(font.getFontSize()));
+
+ return inline;
+ }
+
+ protected void offsetArea(LayoutContext context) {
+ curArea.setOffset(context.getBaseline());
+ }
+}
+