vmote       2003/08/26 09:48:28

  Modified:    src/java/org/apache/fop/fo/flow PageNumberCitation.java
               src/java/org/apache/fop/layoutmgr AddLMVisitor.java
  Log:
  move fo/flow/PageNumberCitation.getInlineArea() to 
layoutmgr/AddLMVisitor.getPageNumberCitationInlineArea()
  
  Revision  Changes    Path
  1.12      +9 -52     xml-fop/src/java/org/apache/fop/fo/flow/PageNumberCitation.java
  
  Index: PageNumberCitation.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/PageNumberCitation.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- PageNumberCitation.java   22 Aug 2003 06:27:34 -0000      1.11
  +++ PageNumberCitation.java   26 Aug 2003 16:48:28 -0000      1.12
  @@ -51,11 +51,6 @@
   package org.apache.fop.fo.flow;
   
   // FOP
  -import org.apache.fop.area.PageViewport;
  -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.Word;
   import org.apache.fop.datatypes.ColorType;
   import org.apache.fop.fo.FOTreeVisitor;
   import org.apache.fop.fo.FONode;
  @@ -93,7 +88,6 @@
       private String pageNumber;
       private String refId;
       private TextState ts;
  -    private InlineArea inline = null;
       private boolean unresolved = false;
   
       /**
  @@ -111,52 +105,11 @@
           fontInfo = foih.getFontInfo();
       }
   
  -    // if id can be resolved then simply return a word, otherwise
  -    // return a resolveable area
  -    public InlineArea getInlineArea(LayoutProcessor parentLM) {
  -        if (refId.equals("")) {
  -            getLogger().error("page-number-citation must contain \"ref-id\"");
  -            return null;
  -        }
  -        PageViewport page = parentLM.resolveRefID(refId);
  -        if (page != null) {
  -            String str = page.getPageNumber();
  -            // get page string from parent, build area
  -            Word word = new Word();
  -            inline = word;
  -            int width = getStringWidth(str);
  -            word.setWord(str);
  -            inline.setIPD(width);
  -            inline.setHeight(fontState.getAscender()
  -                             - fontState.getDescender());
  -            inline.setOffset(fontState.getAscender());
  -
  -            inline.addTrait(Trait.FONT_NAME, fontState.getFontName());
  -            inline.addTrait(Trait.FONT_SIZE,
  -                            new Integer(fontState.getFontSize()));
  -            unresolved = false;
  -        } else {
  -            unresolved = true;
  -            inline = new UnresolvedPageNumber(refId);
  -            String str = "MMM"; // reserve three spaces for page number
  -            int width = getStringWidth(str);
  -            inline.setIPD(width);
  -            inline.setHeight(fontState.getAscender()
  -                             - fontState.getDescender());
  -            inline.setOffset(fontState.getAscender());
  -
  -            inline.addTrait(Trait.FONT_NAME, fontState.getFontName());
  -            inline.addTrait(Trait.FONT_SIZE,
  -                            new Integer(fontState.getFontSize()));
  -        }
  -        return inline;
  -    }
  -
       /**
        * @param str string to be measured
        * @return width (in millipoints ??) of the string
        */
  -    protected int getStringWidth(String str) {
  +    public int getStringWidth(String str) {
           int width = 0;
           for (int count = 0; count < str.length(); count++) {
               width += CharUtilities.getCharWidth(str.charAt(count),
  @@ -222,16 +175,20 @@
           return refId;
       }
   
  -    public InlineArea getInline() {
  -        return inline;
  -    }
  -
       public boolean getUnresolved() {
           return unresolved;
       }
   
  +    public void setUnresolved(boolean isUnresolved) {
  +        unresolved = isUnresolved;
  +    }
  +
       public void acceptVisitor(FOTreeVisitor fotv) {
           fotv.serveVisitor(this);
  +    }
  +
  +    public Font getFontState() {
  +        return fontState;
       }
   
   }
  
  
  
  1.12      +48 -3     xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
  
  Index: AddLMVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AddLMVisitor.java 26 Aug 2003 15:05:33 -0000      1.11
  +++ AddLMVisitor.java 26 Aug 2003 16:48:28 -0000      1.12
  @@ -60,6 +60,7 @@
   import org.apache.fop.area.inline.FilledArea;
   import org.apache.fop.area.inline.ForeignObject;
   import org.apache.fop.area.inline.Space;
  +import org.apache.fop.area.inline.UnresolvedPageNumber;
   import org.apache.fop.area.inline.Word;
   import org.apache.fop.area.inline.Image;
   import org.apache.fop.area.inline.Viewport;
  @@ -712,7 +713,8 @@
            LayoutManager lm;
            lm = new LeafNodeLayoutManager() {
                        public InlineArea get(LayoutContext context) {
  -                         return node.getInlineArea(parentLM);
  +                         curArea = getPageNumberCitationInlineArea(node, parentLM);
  +                         return curArea;
                        }
   
                        public void addAreas(PositionIterator posIter,
  @@ -720,7 +722,7 @@
                            super.addAreas(posIter, context);
                            if (node.getUnresolved()) {
                                parentLM.addUnresolvedArea(node.getRefId(),
  -                                                        (Resolveable) 
node.getInline());
  +                                                        (Resolveable) curArea);
                            }
                        }
   
  @@ -731,6 +733,49 @@
            lm.setUserAgent(node.getUserAgent());
            lm.setFObj(node);
            currentLMList.add(lm);
  +     }
  +
  +     // if id can be resolved then simply return a word, otherwise
  +     // return a resolveable area
  +     public InlineArea getPageNumberCitationInlineArea(PageNumberCitation node,
  +             LayoutProcessor parentLM) {
  +         if (node.getRefId().equals("")) {
  +             node.getLogger().error("page-number-citation must contain \"ref-id\"");
  +             return null;
  +         }
  +         PageViewport page = parentLM.resolveRefID(node.getRefId());
  +         InlineArea inline = null;
  +         if (page != null) {
  +             String str = page.getPageNumber();
  +             // get page string from parent, build area
  +             Word word = new Word();
  +             inline = word;
  +             int width = node.getStringWidth(str);
  +             word.setWord(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()));
  +             node.setUnresolved(false);
  +         } else {
  +             node.setUnresolved(true);
  +             inline = new UnresolvedPageNumber(node.getRefId());
  +             String str = "MMM"; // reserve three spaces for page number
  +             int width = node.getStringWidth(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;
        }
   
        public void serveVisitor(Table node) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to