diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-11-18 16:56:09 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-11-18 16:56:09 +0000 |
commit | edc6153b9a6e328c23d32b3ab5a0b493319b0ccb (patch) | |
tree | 75d8a208e18fa3618e39510c5cc70ceaf2a3c38d | |
parent | 42efdd9b247d07833edbbd4796178677762d8910 (diff) | |
download | xmlgraphics-fop-edc6153b9a6e328c23d32b3ab5a0b493319b0ccb.tar.gz xmlgraphics-fop-edc6153b9a6e328c23d32b3ab5a0b493319b0ccb.zip |
Bugzilla #43605:
Added methods for page-number-citation and page-number-citation-last in FOEventHandler.java
Submitted by: V. Schappert <vschappert.at.bloomberg.net>
Patch modified by Jeremias:
Bugfix: FOEventHandler.startPageNumberCitation() was also called in the case of a page-number-citation-last. Introduced abstract base classes to avoid this.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@596097 13f79535-47bb-0310-9956-ffa450edef68
8 files changed, 401 insertions, 229 deletions
diff --git a/src/java/org/apache/fop/fo/FOEventHandler.java b/src/java/org/apache/fop/fo/FOEventHandler.java index b2297ae6f..4af703c12 100644 --- a/src/java/org/apache/fop/fo/FOEventHandler.java +++ b/src/java/org/apache/fop/fo/FOEventHandler.java @@ -19,12 +19,11 @@ package org.apache.fop.fo; -// Java import java.util.HashSet; import java.util.Set; + import org.xml.sax.SAXException; -// Apache import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.flow.BasicLink; import org.apache.fop.fo.flow.Block; @@ -39,6 +38,8 @@ import org.apache.fop.fo.flow.Leader; import org.apache.fop.fo.flow.ListBlock; import org.apache.fop.fo.flow.ListItem; import org.apache.fop.fo.flow.PageNumber; +import org.apache.fop.fo.flow.PageNumberCitation; +import org.apache.fop.fo.flow.PageNumberCitationLast; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; import org.apache.fop.fo.flow.table.TableCell; @@ -48,7 +49,6 @@ import org.apache.fop.fo.pagination.Flow; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.fonts.FontInfo; - /** * Abstract class defining what should be done with SAX events that map to * XSL-FO input. The events are actually captured by fo/FOTreeBuilder, passed @@ -207,6 +207,34 @@ public abstract class FOEventHandler { } /** + * + * @param pageCite PageNumberCitation that is starting. + */ + public void startPageNumberCitation(PageNumberCitation pageCite) { + } + + /** + * + * @param pageCite PageNumberCitation that is ending. + */ + public void endPageNumberCitation(PageNumberCitation pageCite) { + } + + /** + * + * @param pageLast PageNumberCitationLast that is starting. + */ + public void startPageNumberCitationLast(PageNumberCitationLast pageLast) { + } + + /** + * + * @param pageLast PageNumberCitationLast that is ending. + */ + public void endPageNumberCitationLast(PageNumberCitationLast pageLast) { + } + + /** * This method is called to indicate the start of a new fo:flow * or fo:static-content. * This method also handles fo:static-content tags, because the diff --git a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java new file mode 100644 index 000000000..b6b827248 --- /dev/null +++ b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.fo.flow; + +import java.awt.Color; + +import org.xml.sax.Locator; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.Length; +import org.apache.fop.fo.Constants; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.CommonBorderPaddingBackground; +import org.apache.fop.fo.properties.CommonFont; +import org.apache.fop.fo.properties.CommonTextDecoration; +import org.apache.fop.fo.properties.SpaceProperty; + +/** + * Base class modelling the fo:page-number-citation object. + */ +public abstract class AbstractPageNumberCitation extends FObj { + + // The value of properties relevant for fo:page-number-citation(-last). + private CommonBorderPaddingBackground commonBorderPaddingBackground; + private CommonFont commonFont; + private Length alignmentAdjust; + private int alignmentBaseline; + private Length baselineShift; + private int dominantBaseline; + // private ToBeImplementedProperty letterSpacing; + private SpaceProperty lineHeight; + private String refId; + /** Holds the text decoration values. May be null */ + private CommonTextDecoration textDecoration; + // private ToBeImplementedProperty textShadow; + // Unused but valid items, commented out for performance: + // private CommonAccessibility commonAccessibility; + // private CommonAural commonAural; + // private CommonMarginInline commonMarginInline; + // private CommonRelativePosition commonRelativePosition; + // private KeepProperty keepWithNext; + // private KeepProperty keepWithPrevious; + // private int scoreSpaces; + // private Length textAltitude; + // private Length textDepth; + // private int textTransform; + // private int visibility; + // private SpaceProperty wordSpacing; + // private int wrapOption; + // End of property values + + // Properties which are not explicitely listed but are still applicable + private Color color; + + /** + * @param parent FONode that is the parent of this object + */ + public AbstractPageNumberCitation(FONode parent) { + super(parent); + } + + /** + * {@inheritDoc} + */ + public void bind(PropertyList pList) throws FOPException { + super.bind(pList); + commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); + commonFont = pList.getFontProps(); + alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); + alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); + baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); + dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); + // letterSpacing = pList.get(PR_LETTER_SPACING); + lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); + refId = pList.get(PR_REF_ID).getString(); + textDecoration = pList.getTextDecorationProps(); + // textShadow = pList.get(PR_TEXT_SHADOW); + + // implicit properties + color = pList.get(Constants.PR_COLOR).getColor(getUserAgent()); + } + + /** {@inheritDoc} */ + protected void startOfNode() throws FOPException { + super.startOfNode(); + if (refId.equals("")) { + missingPropertyError("ref-id"); + } + } + + /** + * {@inheritDoc} + * XSL Content Model: empty + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws ValidationException { + invalidChildError(loc, nsURI, localName); + } + + /** @return the Common Font Properties. */ + public CommonFont getCommonFont() { + return commonFont; + } + + /** @return the "color" property. */ + public Color getColor() { + return color; + } + + /** @return the "text-decoration" property. */ + public CommonTextDecoration getTextDecoration() { + return textDecoration; + } + + /** + * @return the "alignment-adjust" property + */ + public Length getAlignmentAdjust() { + return alignmentAdjust; + } + + /** + * @return the "alignment-baseline" property + */ + public int getAlignmentBaseline() { + return alignmentBaseline; + } + + /** + * @return the "baseline-shift" property + */ + public Length getBaselineShift() { + return baselineShift; + } + + /** + * @return the "dominant-baseline" property + */ + public int getDominantBaseline() { + return dominantBaseline; + } + + /** @return the Common Border, Padding, and Background Properties. */ + public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { + return commonBorderPaddingBackground; + } + + /** + * @return the "line-height" property + */ + public SpaceProperty getLineHeight() { + return lineHeight; + } + + /** @return the "ref-id" property. */ + public String getRefId() { + return refId; + } + +} diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index dc824e142..feea07433 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java @@ -19,21 +19,8 @@ package org.apache.fop.fo.flow; -import java.awt.Color; - -import org.xml.sax.Locator; - import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.Length; -import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FObj; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.fo.properties.CommonFont; -import org.apache.fop.fo.properties.CommonTextDecoration; -import org.apache.fop.fo.properties.SpaceProperty; /** * Class modelling the fo:page-number-citation object. @@ -41,146 +28,28 @@ import org.apache.fop.fo.properties.SpaceProperty; * The page number used is the page that contains the start of the * block referenced with the ref-id attribute. */ -public class PageNumberCitation extends FObj { - // The value of properties relevant for fo:page-number-citation. - private CommonBorderPaddingBackground commonBorderPaddingBackground; - private CommonFont commonFont; - private Length alignmentAdjust; - private int alignmentBaseline; - private Length baselineShift; - private int dominantBaseline; - // private ToBeImplementedProperty letterSpacing; - private SpaceProperty lineHeight; - private String refId; - /** Holds the text decoration values. May be null */ - private CommonTextDecoration textDecoration; - // private ToBeImplementedProperty textShadow; - // Unused but valid items, commented out for performance: - // private CommonAccessibility commonAccessibility; - // private CommonAural commonAural; - // private CommonMarginInline commonMarginInline; - // private CommonRelativePosition commonRelativePosition; - // private KeepProperty keepWithNext; - // private KeepProperty keepWithPrevious; - // private int scoreSpaces; - // private Length textAltitude; - // private Length textDepth; - // private int textTransform; - // private int visibility; - // private SpaceProperty wordSpacing; - // private int wrapOption; - // End of property values - - // Properties which are not explicitely listed but are still applicable - private Color color; +public class PageNumberCitation extends AbstractPageNumberCitation { /** + * Main constructor * @param parent FONode that is the parent of this object */ public PageNumberCitation(FONode parent) { super(parent); } - /** - * {@inheritDoc} - */ - public void bind(PropertyList pList) throws FOPException { - super.bind(pList); - commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); - commonFont = pList.getFontProps(); - alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); - alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); - baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); - dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); - // letterSpacing = pList.get(PR_LETTER_SPACING); - lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); - refId = pList.get(PR_REF_ID).getString(); - textDecoration = pList.getTextDecorationProps(); - // textShadow = pList.get(PR_TEXT_SHADOW); - - // implicit properties - color = pList.get(Constants.PR_COLOR).getColor(getUserAgent()); - } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); - if (refId.equals("")) { - missingPropertyError("ref-id"); - } - } - - /** - * {@inheritDoc} - * XSL Content Model: empty - */ - protected void validateChildNode(Locator loc, String nsURI, String localName) - throws ValidationException { - invalidChildError(loc, nsURI, localName); - } - - /** @return the Common Font Properties. */ - public CommonFont getCommonFont() { - return commonFont; - } - - /** @return the "color" property. */ - public Color getColor() { - return color; + getFOEventHandler().startPageNumberCitation(this); } - /** @return the "text-decoration" property. */ - public CommonTextDecoration getTextDecoration() { - return textDecoration; - } - - /** - * @return the "alignment-adjust" property - */ - public Length getAlignmentAdjust() { - return alignmentAdjust; - } - - /** - * @return the "alignment-baseline" property - */ - public int getAlignmentBaseline() { - return alignmentBaseline; - } - - /** - * @return the "baseline-shift" property - */ - public Length getBaselineShift() { - return baselineShift; - } - - /** - * @return the "dominant-baseline" property - */ - public int getDominantBaseline() { - return dominantBaseline; - } - - /** @return the Common Border, Padding, and Background Properties. */ - public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { - return commonBorderPaddingBackground; + /** {@inheritDoc} */ + protected void endOfNode() throws FOPException { + super.endOfNode(); + getFOEventHandler().endPageNumberCitation(this); } - /** - * @return the "line-height" property - */ - public SpaceProperty getLineHeight() { - return lineHeight; - } - - /** @return the "ref-id" property. */ - public String getRefId() { - return refId; - } - /** {@inheritDoc} */ public String getLocalName() { return "page-number-citation"; diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java b/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java index 44ef52aec..a9b5b90df 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java @@ -19,6 +19,7 @@ package org.apache.fop.fo.flow; +import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; /** @@ -28,7 +29,7 @@ import org.apache.fop.fo.FONode; * block referenced with the ref-id attribute. * @since XSL 1.1 */ -public class PageNumberCitationLast extends PageNumberCitation { +public class PageNumberCitationLast extends AbstractPageNumberCitation { /** * Main constructor @@ -39,6 +40,18 @@ public class PageNumberCitationLast extends PageNumberCitation { } /** {@inheritDoc} */ + protected void startOfNode() throws FOPException { + super.startOfNode(); + getFOEventHandler().startPageNumberCitationLast(this); + } + + /** {@inheritDoc} */ + protected void endOfNode() throws FOPException { + super.endOfNode(); + getFOEventHandler().endPageNumberCitationLast(this); + } + + /** {@inheritDoc} */ public String getLocalName() { return "page-number-citation-last"; } @@ -47,4 +60,5 @@ public class PageNumberCitationLast extends PageNumberCitation { public int getNameId() { return FO_PAGE_NUMBER_CITATION_LAST; } + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java new file mode 100644 index 000000000..41d4af1c1 --- /dev/null +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.inline; + +import org.apache.fop.area.PageViewport; +import org.apache.fop.area.Resolvable; +import org.apache.fop.area.Trait; +import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.area.inline.TextArea; +import org.apache.fop.area.inline.UnresolvedPageNumber; +import org.apache.fop.fo.flow.AbstractPageNumberCitation; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontTriplet; +import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.TraitSetter; + +/** + * LayoutManager for the fo:page-number-citation(-last) formatting object + */ +public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLayoutManager { + + /** The page number citation object */ + protected AbstractPageNumberCitation fobj; + /** Font for the page-number-citation */ + protected Font font; + + /** Indicates whether the page referred to by the citation has been resolved yet */ + protected boolean resolved = false; + + /** + * Constructor + * + * @param node the formatting object that creates this area + * @todo better retrieval of font info + */ + public AbstractPageNumberCitationLayoutManager(AbstractPageNumberCitation node) { + super(node); + fobj = node; + } + + /** {@inheritDoc} */ + public void initialize() { + FontInfo fi = fobj.getFOEventHandler().getFontInfo(); + FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); + font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this)); + setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground()); + } + + /** + * {@inheritDoc} + */ + protected AlignmentContext makeAlignmentContext(LayoutContext context) { + return new AlignmentContext( + font + , fobj.getLineHeight().getOptimum(this).getLength().getValue(this) + , fobj.getAlignmentAdjust() + , fobj.getAlignmentBaseline() + , fobj.getBaselineShift() + , fobj.getDominantBaseline() + , context.getAlignmentContext() + ); + } + + /** {@inheritDoc} */ + public InlineArea get(LayoutContext context) { + curArea = getPageNumberCitationInlineArea(parentLM); + return curArea; + } + + /** + * {@inheritDoc} + * , LayoutContext) + */ + public void addAreas(PositionIterator posIter, LayoutContext context) { + super.addAreas(posIter, context); + if (!resolved) { + getPSLM().addUnresolvedArea(fobj.getRefId(), (Resolvable) curArea); + } + } + + /** + * if id can be resolved then simply return a word, otherwise + * return a resolvable area + */ + private InlineArea getPageNumberCitationInlineArea(LayoutManager parentLM) { + PageViewport page = getPSLM().getFirstPVWithID(fobj.getRefId()); + TextArea text = null; + if (page != null) { + String str = page.getPageNumberString(); + // get page string from parent, build area + text = new TextArea(); + int width = getStringWidth(str); + text.addWord(str, 0); + text.setIPD(width); + resolved = true; + } else { + resolved = false; + text = new UnresolvedPageNumber(fobj.getRefId(), font); + String str = "MMM"; // reserve three spaces for page number + int width = getStringWidth(str); + text.setIPD(width); + } + updateTextAreaTraits(text); + + return text; + } + + /** + * Updates the traits for the generated text area. + * @param text the text area + */ + protected void updateTextAreaTraits(TextArea text) { + TraitSetter.setProducerID(text, fobj.getId()); + text.setBPD(font.getAscender() - font.getDescender()); + text.setBaselineOffset(font.getAscender()); + TraitSetter.addFontTraits(text, font); + text.addTrait(Trait.COLOR, fobj.getColor()); + TraitSetter.addTextDecoration(text, fobj.getTextDecoration()); + } + + /** + * @param str string to be measured + * @return width (in millipoints ??) of the string + */ + protected int getStringWidth(String str) { + int width = 0; + for (int count = 0; count < str.length(); count++) { + width += font.getCharWidth(str.charAt(count)); + } + return width; + } + + /** {@inheritDoc} */ + protected void addId() { + getPSLM().addIDToPage(fobj.getId()); + } +} + diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java index c012f351e..331d48b75 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java @@ -19,22 +19,20 @@ package org.apache.fop.layoutmgr.inline; -import org.apache.fop.fo.flow.PageNumberCitationLast; import org.apache.fop.area.PageViewport; import org.apache.fop.area.Resolvable; import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.UnresolvedPageNumber; import org.apache.fop.area.inline.TextArea; +import org.apache.fop.area.inline.UnresolvedPageNumber; +import org.apache.fop.fo.flow.PageNumberCitationLast; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.LayoutManager; /** * LayoutManager for the fo:page-number-citation-last formatting object */ -public class PageNumberCitationLastLayoutManager extends PageNumberCitationLayoutManager { +public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitationLayoutManager { - private PageNumberCitationLast fobj; - /** * Constructor * diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java index f3a83b9f2..4f5c78540 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java @@ -19,33 +19,19 @@ package org.apache.fop.layoutmgr.inline; -import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.area.PageViewport; -import org.apache.fop.area.Resolvable; -import org.apache.fop.area.Trait; import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.UnresolvedPageNumber; import org.apache.fop.area.inline.TextArea; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontTriplet; +import org.apache.fop.area.inline.UnresolvedPageNumber; +import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.LayoutManager; -import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.TraitSetter; /** * LayoutManager for the fo:page-number-citation formatting object */ -public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager { +public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationLayoutManager { - private PageNumberCitation fobj; - /** Font for the page-number-citation */ - protected Font font; - - /** Indicates whether the page referred to by the citation has been resolved yet */ - protected boolean resolved = false; - /** * Constructor * @@ -54,50 +40,15 @@ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager { */ public PageNumberCitationLayoutManager(PageNumberCitation node) { super(node); - fobj = node; } /** {@inheritDoc} */ - public void initialize() { - FontInfo fi = fobj.getFOEventHandler().getFontInfo(); - FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); - font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this)); - setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground()); - } - - /** - * {@inheritDoc} - */ - protected AlignmentContext makeAlignmentContext(LayoutContext context) { - return new AlignmentContext( - font - , fobj.getLineHeight().getOptimum(this).getLength().getValue(this) - , fobj.getAlignmentAdjust() - , fobj.getAlignmentBaseline() - , fobj.getBaselineShift() - , fobj.getDominantBaseline() - , context.getAlignmentContext() - ); - } - - /** {@inheritDoc} */ public InlineArea get(LayoutContext context) { curArea = getPageNumberCitationInlineArea(parentLM); return curArea; } /** - * {@inheritDoc} - * , LayoutContext) - */ - public void addAreas(PositionIterator posIter, LayoutContext context) { - super.addAreas(posIter, context); - if (!resolved) { - getPSLM().addUnresolvedArea(fobj.getRefId(), (Resolvable) curArea); - } - } - - /** * if id can be resolved then simply return a word, otherwise * return a resolvable area */ @@ -124,34 +75,5 @@ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager { return text; } - /** - * Updates the traits for the generated text area. - * @param text the text area - */ - protected void updateTextAreaTraits(TextArea text) { - TraitSetter.setProducerID(text, fobj.getId()); - text.setBPD(font.getAscender() - font.getDescender()); - text.setBaselineOffset(font.getAscender()); - TraitSetter.addFontTraits(text, font); - text.addTrait(Trait.COLOR, fobj.getColor()); - TraitSetter.addTextDecoration(text, fobj.getTextDecoration()); - } - - /** - * @param str string to be measured - * @return width (in millipoints ??) of the string - */ - protected int getStringWidth(String str) { - int width = 0; - for (int count = 0; count < str.length(); count++) { - width += font.getCharWidth(str.charAt(count)); - } - return width; - } - - /** {@inheritDoc} */ - protected void addId() { - getPSLM().addIDToPage(fobj.getId()); - } } diff --git a/status.xml b/status.xml index 36c7aa5b0..20df48aad 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,9 @@ <changes> <release version="FOP Trunk"> + <action context="Code" dev="JM" type="add" fixes-bug="43605" due-to="V. Schappert"> + Added methods for fo:page-number-citation(-last) in FOEventHandler. + </action> <action context="Code" dev="VH" type="add"> Step towards performance: the collapsing-border resolution algorithm no longer triggers the retrieving of the whole table, when possible. |