]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
This patch implements a pluggable LayoutManagers system, according
authorSimon Pepping <spepping@apache.org>
Fri, 24 Dec 2004 12:06:26 +0000 (12:06 +0000)
committerSimon Pepping <spepping@apache.org>
Fri, 24 Dec 2004 12:06:26 +0000 (12:06 +0000)
to the ideas of Finn Bock and his patch in bug 30500.

Created a LayoutManagerMaker interface, with method
makeLayoutManagers(FONode, List), and two convenience methods on top
of it.

Created an implementation: LayoutManagerMapping. This is along the
pattern of FOElementMapping. It creates a Map from FObj class to Maker
objects. There are many static inner classes which are subclasses of
Maker. Each subclass implements its own version of the make method.

FOUserAgent has a setter and getter for
LayoutManagerMakerOverride. AreaTreeHandler creates a
LayoutManagerMaker, taking the user's override into account, using
LayoutManagerMapping as the default. It has a get method for it.

The LayoutManager interface has a get method for the AreaTreeHandler
object, a reference to which is held in PageSequenceLM, the top of the
LM tree.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198208 13f79535-47bb-0310-9956-ffa450edef68

35 files changed:
src/java/org/apache/fop/apps/FOUserAgent.java
src/java/org/apache/fop/area/AreaTreeHandler.java
src/java/org/apache/fop/fo/FONode.java
src/java/org/apache/fop/fo/FOText.java
src/java/org/apache/fop/fo/FObjMixed.java
src/java/org/apache/fop/fo/flow/BasicLink.java
src/java/org/apache/fop/fo/flow/BidiOverride.java
src/java/org/apache/fop/fo/flow/Block.java
src/java/org/apache/fop/fo/flow/BlockContainer.java
src/java/org/apache/fop/fo/flow/Character.java
src/java/org/apache/fop/fo/flow/ExternalGraphic.java
src/java/org/apache/fop/fo/flow/Footnote.java
src/java/org/apache/fop/fo/flow/Inline.java
src/java/org/apache/fop/fo/flow/InlineContainer.java
src/java/org/apache/fop/fo/flow/InlineLevel.java
src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
src/java/org/apache/fop/fo/flow/Leader.java
src/java/org/apache/fop/fo/flow/ListBlock.java
src/java/org/apache/fop/fo/flow/ListItem.java
src/java/org/apache/fop/fo/flow/Marker.java
src/java/org/apache/fop/fo/flow/PageNumber.java
src/java/org/apache/fop/fo/flow/PageNumberCitation.java
src/java/org/apache/fop/fo/flow/RetrieveMarker.java
src/java/org/apache/fop/fo/flow/Table.java
src/java/org/apache/fop/fo/flow/TableBody.java
src/java/org/apache/fop/fo/flow/TableCell.java
src/java/org/apache/fop/fo/flow/TableRow.java
src/java/org/apache/fop/fo/flow/Wrapper.java
src/java/org/apache/fop/fo/pagination/Flow.java
src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/LayoutManager.java
src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java

index dcdbb189dbe29feff0980083e0cdc64cc6abe93c..7e669843a402d376d36e35093bff0bd80051a3f2 100644 (file)
@@ -37,6 +37,7 @@ import org.apache.commons.logging.LogFactory;
 // FOP
 import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.FOEventHandler;
+import org.apache.fop.layoutmgr.LayoutManagerMaker;
 import org.apache.fop.pdf.PDFEncryptionParams;
 import org.apache.fop.render.Renderer;
 
@@ -74,6 +75,7 @@ public class FOUserAgent {
     private InputHandler inputHandler = null;
     private Renderer rendererOverride = null;
     private FOEventHandler foEventHandlerOverride = null;
+    private LayoutManagerMaker lmMakerOverride = null;
     /* user configuration */
     private Configuration userConfig = null;
     private Log log = LogFactory.getLog("FOP");
@@ -166,6 +168,23 @@ public class FOUserAgent {
         return this.foEventHandlerOverride;
     }
 
+    /**
+     * Sets an explicit LayoutManagerMaker instance which overrides the one
+     * defined by the AreaTreeHandler.
+     * @param lmMaker the LayoutManagerMaker instance
+     */
+    public void setLayoutManagerMakerOverride(LayoutManagerMaker lmMaker) {
+        this.lmMakerOverride = lmMaker;
+    }
+
+    /**
+     * Returns the overriding LayoutManagerMaker instance, if any.
+     * @return the overriding LayoutManagerMaker or null
+     */
+    public LayoutManagerMaker getLayoutManagerMakerOverride() {
+        return this.lmMakerOverride;
+    }
+
     /**
      * Sets the producer of the document.  
      * @param producer source of document
index df60e0cbbf2242bacb0e468aeccc88e972dc487c..fe0972da9189c921686b3b3a31ed84b3993d44c0 100644 (file)
@@ -40,6 +40,8 @@ import org.apache.fop.fo.extensions.Bookmarks;
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fo.pagination.Root;
 import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
+import org.apache.fop.layoutmgr.LayoutManagerMaker;
+import org.apache.fop.layoutmgr.LayoutManagerMapping;
 
 /**
  * Area tree handler for formatting objects.
@@ -72,6 +74,9 @@ public class AreaTreeHandler extends FOEventHandler {
     // time used in rendering (for statistics)
     private long startTime;
 
+    // the LayoutManager maker
+    private LayoutManagerMaker lmMaker;
+
     // count of number of pages rendered
     private int pageCount;
 
@@ -106,6 +111,11 @@ public class AreaTreeHandler extends FOEventHandler {
         model = new RenderPagesModel(userAgent, renderType, fontInfo,
             stream);
             
+        lmMaker = userAgent.getLayoutManagerMakerOverride();
+        if (lmMaker == null) {
+            lmMaker = new LayoutManagerMapping();
+        }
+
         outputStatistics = log.isDebugEnabled();
 
         if (outputStatistics) {
@@ -122,6 +132,15 @@ public class AreaTreeHandler extends FOEventHandler {
         return model;
     }
 
+    /**
+     * Get the LayoutManager maker for this area tree.
+     *
+     * @return LayoutManagerMaker the LayoutManager maker being used for this area tree
+     */
+    public LayoutManagerMaker getLayoutManagerMaker() {
+        return lmMaker;
+    }
+
     /**
      * Tie a PageViewport with an ID found on a child area of the PV.
      * Note that an area with a given ID may be on more than one PV, hence
@@ -210,8 +229,10 @@ public class AreaTreeHandler extends FOEventHandler {
 
         // If no main flow, nothing to layout!
         if (pageSequence.getMainFlow() != null) {
-            PageSequenceLayoutManager pageSLM 
-                = new PageSequenceLayoutManager(this, pageSequence);
+            PageSequenceLayoutManager pageSLM =
+                (PageSequenceLayoutManager)
+                getLayoutManagerMaker().makeLayoutManager(pageSequence);
+            pageSLM.setAreaTreeHandler(this);
             pageSLM.activateLayout();
         }
     }
index ed8959813c8395d65b85c11bb47a44dc7a76b28a..ec6dc59bb2b3553fc30780630b1b535b139bb598 100644 (file)
@@ -370,14 +370,6 @@ public abstract class FONode implements Cloneable {
         }
     }
 
-    /**
-     * Return a LayoutManager responsible for laying out this FObj's content.
-     * Must override in subclasses if their content can be laid out.
-     * @param list the list to which the layout manager(s) should be added
-     */
-    public void addLayoutManager(List list) {
-    }
-
     /**
      * Returns the name of the node
      * @return the name of this node
index 7c477dfb6a164563ca9bf94b20d9b8a1848c33cc..43ecc76df4f8c0147391db8904d13714308c8bc3 100644 (file)
@@ -567,13 +567,4 @@ public class FOText extends FONode {
     public int getWrapOption() {
         return wrapOption; 
     }
-
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        if (endIndex - startIndex > 0) {
-            list.add(new TextLayoutManager(this));
-        }
-    }
 }
index 9c338f4ca4b35ad2d7cf028f299e7c01f2baf2f2..37f8724af23f85bf6a149fbf6847024d53660a57 100644 (file)
@@ -61,13 +61,6 @@ public class FObjMixed extends FObj {
     public CharIterator charIterator() {
         return new RecursiveCharIterator(this);
     }
-
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {    
-        // no layout manager
-    }
     
 }
 
index 4a74cbf2d1c0c6bfb6805e3f750900e512e58d1d..9687bfda2656e8a652f1caf55446ce0148732c93 100644 (file)
@@ -117,14 +117,6 @@ public class BasicLink extends Inline {
         }
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {    
-        BasicLinkLayoutManager lm = new BasicLinkLayoutManager(this);
-        list.add(lm);
-    }
-
     /**
      * Return the "internal-destination" property.
      */
index f7d6219ecd8f9cf36611a63ee09bc1260acd1929..3f3bd45299efc5f62f53ad3452d46e6d361f8c68 100644 (file)
@@ -132,30 +132,6 @@ public class BidiOverride extends FObjMixed {
             blockOrInlineItemFound = true;
         }
     }
-    
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     * @todo see if can/should move the child iteration logic 
-     *      to BidiLayoutManager
-     */
-    public void addLayoutManager(List list) {    
-        if (false) {
-            super.addLayoutManager(list);
-        } else {
-            ArrayList childList = new ArrayList();
-            super.addLayoutManager(list);
-            for (int count = childList.size() - 1; count >= 0; count--) {
-                LayoutManager lm = (LayoutManager) childList.get(count);
-                if (lm.generatesInlineAreas()) {
-                    LayoutManager blm = new BidiLayoutManager(this,
-                        (InlineLayoutManager) lm);
-                    list.add(blm);
-                } else {
-                    list.add(lm);
-                }
-            }
-        }
-    }
 
     /**
      * @see org.apache.fop.fo.FObj#getName()
index e21fe926a0f9cec7791c721a822769c75bc22145..b99d49c4025c9b21336ff58e5fa15021944d0a86 100644 (file)
@@ -473,14 +473,6 @@ public class Block extends FObjMixed {
             bNextIsLF = false;
         }
     }
-
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {    
-        BlockLayoutManager blm = new BlockLayoutManager(this);
-        list.add(blm);
-    }
      
     /**
      * @see org.apache.fop.fo.FONode#getName()
index ab0260d925c8d2a75e56e006802b6597f77ba0cb..cc44c9d13bed5090ef4c90b068ac93e42ae76edb 100644 (file)
@@ -189,14 +189,6 @@ public class BlockContainer extends FObj {
         return writingMode;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {    
-        BlockContainerLayoutManager blm = new BlockContainerLayoutManager(this);
-        list.add(blm);
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 445f9d339ae26ab95ec3ee72d8cba5c5206a2af8..e4f67726ad7792f9e49c836137086687ea50cc74 100644 (file)
@@ -233,14 +233,6 @@ public class Character extends FObj {
         return verticalAlign; 
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        CharacterLayoutManager lm = new CharacterLayoutManager(this);
-        list.add(lm);
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 4a9308b13a21f29bb489614029122d6fe59edd8e..55c5a567dba9631a5e284d6137337904a5992186 100644 (file)
@@ -240,16 +240,6 @@ public class ExternalGraphic extends FObj {
         return verticalAlign;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        if (!src.equals("")) {
-            ExternalGraphicLayoutManager lm = new ExternalGraphicLayoutManager(this);
-            list.add(lm);
-        }
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 9c40c4fbbf7b2f527703606e7eb24eec76486db1..2d161c2c85ff7e0f0eaf83ae47066bcde3f0a787 100644 (file)
@@ -120,17 +120,6 @@ public class Footnote extends FObj {
         return inlineFO;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        if (getInlineFO() == null) {
-            getLogger().error("inline required in footnote");
-            return;
-        }
-        getInlineFO().addLayoutManager(list);
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index e39c2a8b6a81fe218468cf2cd4d0ed02d14dece0..477e00e37a6e9ac30d642b050452e6360804e259 100644 (file)
@@ -181,16 +181,6 @@ public class Inline extends InlineLevel {
         return new InlineCharIterator(this, commonBorderPaddingBackground);
     }
 
-    /**
-     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {    
-        if (getChildNodes() != null) {
-            InlineLayoutManager lm = new InlineLayoutManager(this);
-            list.add(lm);
-        }
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index c90ed0211ad929a612abb1eb9f29ab109e867bca..6f7d18f01221696784342fd1342ed5ce83071cda 100644 (file)
@@ -113,16 +113,6 @@ public class InlineContainer extends FObj {
         return id;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        ArrayList childList = new ArrayList();
-        super.addLayoutManager(childList);
-        LayoutManager lm = new ICLayoutManager(this, childList);
-        list.add(lm);
-    }
-
     /**
      * @see org.apache.fop.fo.FONode#getName()
      */
index 5ce0a611c9020c6e39484892c42578df893bf8dd..ab468f6ad51ea7c72b2f3e1db9012456f1db7c35 100644 (file)
@@ -96,17 +96,5 @@ public class InlineLevel extends FObjMixed {
     public ColorType getColor() {
         return color;
     }
-
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {    
-        if (getChildNodes() != null) {
-            InlineLayoutManager lm;
-            lm = new InlineLayoutManager(this);
-            list.add(lm);
-        }
-    }
-
 }
 
index 024ccc0c9752d2ca17ba8254de1730f927ed2a43..02b73dd76937f4dfe3bf985b96b1802202e3a193 100644 (file)
@@ -260,14 +260,6 @@ public class InstreamForeignObject extends FObj {
         return overflow;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        InstreamForeignObjectLM lm = new InstreamForeignObjectLM(this);
-        list.add(lm);
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 3e245eec7e796ccc78546ed22ebb15b3177faf2b..16387d6a3e9c13d8e385495f43f5f23d2e64cc1a 100644 (file)
@@ -175,14 +175,6 @@ public class Leader extends InlineLevel {
         return verticalAlign; 
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        LeaderLayoutManager lm = new LeaderLayoutManager(this);
-        list.add(lm);
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 704e19b82d617451c99443bb1d7dbf81e585389e..d0edd4e1b653a4539e51073d8d0f6af79c7f38d9 100644 (file)
@@ -146,14 +146,6 @@ public class ListBlock extends FObj {
         return id;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        ListBlockLayoutManager lm = new ListBlockLayoutManager(this);
-        list.add(lm);
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 7265dee38adf638c5d620bed7ab20f126089dea1..185e074adc73337fac8e43f9a10586d47bc86b94 100644 (file)
@@ -154,14 +154,6 @@ public class ListItem extends FObj {
         return id;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        ListItemLayoutManager blm = new ListItemLayoutManager(this);
-        list.add(blm);
-    }
-
     /**
      * @return the label of the list item
      */
index b8395d0747c0a92d4a04abebe14528e037299f27..feebc64e10ca7757d120a56c5b1dd19425e45b1a 100644 (file)
@@ -122,13 +122,6 @@ public class Marker extends FObjMixed {
         }
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        // no layout manager
-    }
-
     /**
      * Return the "marker-class-name" property.
      */
index c6c11fa45bcf424d63926589140365545cada9c7..3215113c24a586b04a3932f3f91e32250bfe89bb 100644 (file)
@@ -159,14 +159,6 @@ public class PageNumber extends FObj {
         return textDecoration; 
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        PageNumberLayoutManager lm = new PageNumberLayoutManager(this);
-        list.add(lm);
-    }
-
     /**
      * @see org.apache.fop.fo.FONode#getName()
      */
index e9d0ed5c2ed5d386fc77ad8e7995b93576284649..e423045c187c0ba57ec127be4c489a7011d91982 100644 (file)
@@ -151,15 +151,6 @@ public class PageNumberCitation extends FObj {
     public String getRefId() {
         return refId;
     }
-
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        PageNumberCitationLayoutManager lm = 
-            new PageNumberCitationLayoutManager(this);
-        list.add(lm);
-    }
      
     /**
      * @see org.apache.fop.fo.FObj#getName()
index f9d5fd95b76e05d29fb311f06d68c84cdc0c3c49..0ad5b3afa938cc441dd1cdb5d0c81fe20bbe6e6c 100644 (file)
@@ -80,21 +80,6 @@ public class RetrieveMarker extends FObjMixed {
             invalidChildError(loc, nsURI, localName);
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     * @todo remove null check when vCN() & endOfNode() implemented
-     */
-    public void addLayoutManager(List list) {
-        Iterator baseIter = getChildNodes();
-        if (baseIter == null) {
-            return;
-        }
-        while (baseIter.hasNext()) {
-            FONode child = (FONode) baseIter.next();
-            child.addLayoutManager(list);
-        }
-    }
-
     protected PropertyList createPropertyList(PropertyList parent, 
             FOEventHandler foEventHandler) throws FOPException {
         // TODO: A special RetrieveMarkerPropertyList would be more memory
index 9f62ad578b59fa75dfcd2c7190e99f71c9456c65..150739d75fa88e521ffc3e110692b9d8a92ace0b 100644 (file)
@@ -153,15 +153,15 @@ public class Table extends FObj {
         }
     }
 
-    private ArrayList getColumns() {
+    public ArrayList getColumns() {
         return columns;
     }
 
-    private TableBody getTableHeader() {
+    public TableBody getTableHeader() {
         return tableHeader;
     }
 
-    private TableBody getTableFooter() {
+    public TableBody getTableFooter() {
         return tableFooter;
     }
 
@@ -186,41 +186,6 @@ public class Table extends FObj {
         return id;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     * @todo see if can/should move much of this logic into TableLayoutManager
-     *      and/or TableBody and TableColumn FO subclasses.
-     */
-    public void addLayoutManager(List list) {
-        TableLayoutManager tlm = new TableLayoutManager(this);
-        ArrayList columns = getColumns();
-        if (columns != null) {
-            ArrayList columnLMs = new ArrayList();
-            ListIterator iter = columns.listIterator();
-            while (iter.hasNext()) {
-                columnLMs.add(getTableColumnLayoutManager((TableColumn)iter.next()));
-            }
-            tlm.setColumns(columnLMs);
-        }
-        if (getTableHeader() != null) {
-            tlm.setTableHeader(getTableBodyLayoutManager(getTableHeader()));
-        }
-        if (getTableFooter() != null) {
-            tlm.setTableFooter(getTableBodyLayoutManager(getTableFooter()));
-        }
-        list.add(tlm);
-    }
-
-    public Column getTableColumnLayoutManager(TableColumn node) {
-         Column clm = new Column(node);
-         return clm;
-    }
-    
-    public Body getTableBodyLayoutManager(TableBody node) {
-         Body blm = new Body(node);
-         return blm;
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 18bc5d631211e5e19805a1ecb065e0474d452024..786bd3148e661b79ca032ef2b493494eef6aedb5 100644 (file)
@@ -91,14 +91,6 @@ public class TableBody extends FObj {
         return commonBorderPaddingBackground;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        Body blm = new Body(this);
-        list.add(blm);
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 755d943d748a21976f78830eca28d968e4ac9335..37f35cf33382d9791bdf603f3297dcbfb0994ac8 100644 (file)
@@ -315,14 +315,6 @@ public class TableCell extends FObj {
     public int getNumberRowsSpanned() {
         return Math.max(numberRowsSpanned.getValue(), 1);
     }
-
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        Cell clm = new Cell(this);
-        list.add(clm);
-    }
     
     /**
      * @see org.apache.fop.fo.FObj#getName()
index 873e82f03d6e22e54a8442418cf334c76291777a..222d7b67a60613329246a016d5692271f4d66bf7 100644 (file)
@@ -163,14 +163,6 @@ public class TableRow extends FObj {
     public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
         return commonBorderPaddingBackground;
     }
-
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        Row rlm = new Row(this);
-        list.add(rlm);
-    }
     
     /**
      * @see org.apache.fop.fo.FObj#getName()
index 5a6008ef669354fb061b991c1896e53cb13839e5..1de4327e20ac44d262fc27a120feda5303175422 100644 (file)
@@ -69,21 +69,6 @@ public class Wrapper extends FObjMixed {
         return id;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     * @todo remove null check when vCN() & endOfNode() implemented
-     */
-    public void addLayoutManager(List list) {
-        ListIterator baseIter = getChildNodes();
-        if (baseIter == null) {
-            return;
-        }
-        while (baseIter.hasNext()) {
-            FONode child = (FONode) baseIter.next();
-            child.addLayoutManager(list);
-        }
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 4b3dc610d71c7c77223e4be78b8470da9f32bc18..8ffa067fe0923da7e5df399ac8523d69bd04b787 100644 (file)
@@ -138,14 +138,6 @@ public class Flow extends FObj {
         return flowName;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        FlowLayoutManager lm = new FlowLayoutManager(this);
-        list.add(lm);
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 09edee56f065d7453292d0bc747856beb6ad061b..84f5a90d1fca1bb8b6143e182d3edc58b493b9e8 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Resolvable;
 import org.apache.fop.area.PageViewport;
+import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.RetrieveMarker;
 import org.apache.fop.fo.flow.Marker;
@@ -359,6 +360,16 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
         return parentLM.retrieveMarker(name, pos, boundary);
     }
 
+    /**
+     * Delegate getAreaTreeHandler to the parent layout manager.
+     *
+     * @see org.apache.fop.layoutmgr.LayoutManager
+     * @return the AreaTreeHandler object.
+     */
+    public AreaTreeHandler getAreaTreeHandler() {
+        return parentLM.getAreaTreeHandler();
+    }
+
     /**
      * Convenience method: preload a number of child LMs
      * @param size the requested number of child LMs
@@ -384,7 +395,8 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
                     rm.bindMarker(marker);
                     foNode = rm;
                 }
-                foNode.addLayoutManager(newLMs);
+                getAreaTreeHandler().getLayoutManagerMaker().
+                    makeLayoutManagers(foNode, newLMs);
             }
         }
         return newLMs;
index adc25fd7463b0d9a3c1ee8749204958dfc7fe493..79c1ab6d7c4d364944106d5f9de5b80578540017 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.Marker;
 import org.apache.fop.area.Area;
+import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.Resolvable;
 import org.apache.fop.area.PageViewport;
@@ -44,6 +45,7 @@ import org.apache.commons.logging.LogFactory;
  */
 public class ContentLayoutManager implements InlineLevelLayoutManager {
     private FOUserAgent userAgent;
+    private AreaTreeHandler areaTreeHandler;
     private Area holder;
     private int stackSize;
     private LayoutManager parentLM;
@@ -256,6 +258,31 @@ public class ContentLayoutManager implements InlineLevelLayoutManager {
         return parentLM.retrieveMarker(name, pos, boundary);
     }
 
+    /**
+     * Set the AreaTreeHandler.
+     * This is used by the PageSequenceLM for the Title,
+     * because it does not set itself as the parentLM.
+     * @param areaTreeHandler the area tree handler to add pages to
+     */
+    public void setAreaTreeHandler(AreaTreeHandler areaTreeHandler) {
+        this.areaTreeHandler = areaTreeHandler;
+    }
+
+    /**
+     * Either areaTreeHandler or parentLM should not be null.
+     * If areaTreeHandler is null,
+     * delegate getAreaTreeHandler to the parent layout manager.
+     *
+     * @see org.apache.fop.layoutmgr.LayoutManager
+     * @return the AreaTreeHandler object.
+     */
+    public AreaTreeHandler getAreaTreeHandler() {
+        if (areaTreeHandler == null) {
+            areaTreeHandler = parentLM.getAreaTreeHandler();
+        }
+        return areaTreeHandler;
+    }
+
     /**
      * @see org.apache.fop.layoutmgr.LayoutManager#preLoadNext
      */
index bdc25e605d749fac46d0c6dd279da2ab049c6438..6291a058b82181e1b548c1e77d34698fcdd9aed9 100644 (file)
@@ -26,6 +26,7 @@ import org.apache.fop.fo.flow.Marker;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Resolvable;
 import org.apache.fop.area.PageViewport;
+import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.fo.FObj;
 
 /**
@@ -211,6 +212,11 @@ public interface LayoutManager {
      */
     Marker retrieveMarker(String name, int pos, int boundary);
 
+    /**
+     * @return the AreaTreeHandler object.
+     */
+    AreaTreeHandler getAreaTreeHandler();
+
     /**
      * Load next child LMs, up to child LM index pos
      * @param pos index up to which child LMs are requested
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
new file mode 100644 (file)
index 0000000..4da081c
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 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 java.util.List;
+import org.apache.fop.fo.FONode;
+
+public interface LayoutManagerMaker {
+    
+    public void makeLayoutManagers(FONode node, List lms);
+
+    public LayoutManager makeLayoutManager(FONode node);
+
+    public LayoutManager makeLayoutManager(FONode node, boolean checkLength);
+
+}
+
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
new file mode 100644 (file)
index 0000000..40dd6d9
--- /dev/null
@@ -0,0 +1,387 @@
+/*
+ * Copyright 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Iterator;
+
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FOText;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.FObjMixed;
+import org.apache.fop.fo.XMLObj;
+import org.apache.fop.fo.flow.BasicLink;
+import org.apache.fop.fo.flow.BidiOverride;
+import org.apache.fop.fo.flow.Block;
+import org.apache.fop.fo.flow.BlockContainer;
+import org.apache.fop.fo.flow.Character;
+import org.apache.fop.fo.flow.ExternalGraphic;
+import org.apache.fop.fo.flow.Footnote;
+import org.apache.fop.fo.flow.Inline;
+import org.apache.fop.fo.flow.InlineLevel;
+import org.apache.fop.fo.flow.InlineContainer;
+import org.apache.fop.fo.flow.InstreamForeignObject;
+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.ListItemBody;
+import org.apache.fop.fo.flow.ListItemLabel;
+import org.apache.fop.fo.flow.PageNumber;
+import org.apache.fop.fo.flow.PageNumberCitation;
+import org.apache.fop.fo.flow.RetrieveMarker;
+import org.apache.fop.fo.flow.Table;
+import org.apache.fop.fo.flow.TableBody;
+import org.apache.fop.fo.flow.TableCell;
+import org.apache.fop.fo.flow.TableColumn;
+import org.apache.fop.fo.flow.TableFooter;
+import org.apache.fop.fo.flow.TableHeader;
+import org.apache.fop.fo.flow.TableRow;
+import org.apache.fop.fo.flow.Wrapper;
+import org.apache.fop.fo.pagination.Flow;
+import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.fo.pagination.Title;
+
+import org.apache.fop.layoutmgr.list.Item;
+import org.apache.fop.layoutmgr.list.ListBlockLayoutManager;
+import org.apache.fop.layoutmgr.list.ListItemLayoutManager;
+import org.apache.fop.layoutmgr.table.Body;
+import org.apache.fop.layoutmgr.table.Cell;
+import org.apache.fop.layoutmgr.table.Column;
+import org.apache.fop.layoutmgr.table.Row;
+import org.apache.fop.layoutmgr.table.TableLayoutManager;
+
+/**
+ * The default class for creating layout managers. 
+ */
+public class LayoutManagerMapping implements LayoutManagerMaker {
+
+    /** logging instance */
+    protected static Log log = LogFactory.getLog(LayoutManagerMapping.class);
+
+    /** The map of LayoutManagerMakers */
+    private Map makers = new HashMap();
+
+    public LayoutManagerMapping() {
+        initialize();
+    }
+
+    /**
+     * Initializes the set of maker objects associated with this LayoutManagerMapping
+     */
+    private void initialize() {
+       makers.put(FOText.class, new FOTextLayoutManagerMaker());
+       makers.put(FObjMixed.class, new Maker());
+       makers.put(BidiOverride.class, new BidiOverrideLayoutManagerMaker());
+       makers.put(Inline.class, new InlineLayoutManagerMaker());
+       makers.put(Footnote.class, new FootnodeLayoutManagerMaker());
+       makers.put(InlineContainer.class,
+                   new InlineContainerLayoutManagerMaker());
+       makers.put(BasicLink.class, new BasicLinkLayoutManagerMaker());
+       makers.put(Block.class, new BlockLayoutManagerMaker());
+       makers.put(Leader.class, new LeaderLayoutManagerMaker());
+       makers.put(RetrieveMarker.class, new WrapperLayoutManagerMaker());
+       makers.put(Character.class, new CharacterLayoutManagerMaker());
+       makers.put(ExternalGraphic.class,
+                   new ExternalGraphicLayoutManagerMaker());
+       makers.put(BlockContainer.class,
+                   new BlockContainerLayoutManagerMaker());
+       makers.put(ListItem.class, new ListItemLayoutManagerMaker());
+       makers.put(ListBlock.class, new ListBlockLayoutManagerMaker());
+       makers.put(InstreamForeignObject.class,
+                   new InstreamForeignObjectLayoutManagerMaker());
+       makers.put(PageNumber.class, new PageNumberLayoutManagerMaker());
+       makers.put(PageNumberCitation.class,
+                   new PageNumberCitationLayoutManagerMaker());
+       makers.put(PageSequence.class, new PageSequenceLayoutManagerMaker());
+       makers.put(Table.class, new TableLayoutManagerMaker());
+       makers.put(TableBody.class, new TableBodyLayoutManagerMaker());
+       makers.put(TableColumn.class, new TableColumnLayoutManagerMaker());
+       makers.put(TableRow.class, new TableRowLayoutManagerMaker());
+       makers.put(TableCell.class, new TableCellLayoutManagerMaker());
+       makers.put(TableFooter.class, new TableBodyLayoutManagerMaker());
+       makers.put(TableHeader.class, new TableBodyLayoutManagerMaker());
+       makers.put(Flow.class, new FlowLayoutManagerMaker());
+       makers.put(StaticContent.class, new StaticContentLayoutManagerMaker());
+       makers.put(Wrapper.class, new WrapperLayoutManagerMaker());
+       makers.put(Title.class, new InlineLayoutManagerMaker());
+    }
+    
+    public void makeLayoutManagers(FONode node, List lms) {
+       Maker maker = (Maker) makers.get(node.getClass());
+       if (maker == null) {
+            log.error("No LayoutManager maker for class " + node.getClass());
+        } else {
+               maker.make(node, lms);
+       }
+    }
+
+    public LayoutManager makeLayoutManager(FONode node) {
+        return makeLayoutManager(node, false);
+    }
+
+    public LayoutManager makeLayoutManager(FONode node, boolean checkLength) {
+        List lms = new ArrayList();
+        makeLayoutManagers(node, lms);
+        LayoutManager lm = null;
+        if (checkLength && lms.size() != 1) {
+            log.error("More than 1 LayoutManager for class "
+                      + node.getClass()
+                      + "; 1 was requested"); 
+        } else if (lms.size() != 0) {
+            lm = (LayoutManager) lms.get(0);
+        }
+        return lm;
+    }
+
+       public static class Maker {
+               public void make(FONode node, List lms) {
+            // no layout manager
+                       return;
+               }
+       }
+       
+       public static class FOTextLayoutManagerMaker extends Maker {
+               public void make(FONode node, List lms) {
+                       FOText foText = (FOText) node;
+               if (foText.endIndex - foText.startIndex > 0) {
+                       lms.add(new TextLayoutManager(foText));
+                   }
+               }
+       }
+       
+    /*
+       public static class FObjMixedLayoutManagerMaker extends Maker {
+           public void make(FONode node, List lms) {
+               if (node.getChildNodes() != null) {
+                   InlineStackingLayoutManager lm;
+                   lm = new InlineStackingLayoutManager((FObjMixed) node);
+                   lms.add(lm);
+               }
+           }           
+       }
+    */
+
+       public static class BidiOverrideLayoutManagerMaker extends Maker {
+        // public static class BidiOverrideLayoutManagerMaker extends FObjMixedLayoutManagerMaker {
+           public void make(BidiOverride node, List lms) {
+               if (false) {
+                // this is broken; it does nothing
+                // it should make something like an InlineStackingLM
+                   super.make(node, lms);
+               } else {
+                   ArrayList childList = new ArrayList();
+                // this is broken; it does nothing
+                // it should make something like an InlineStackingLM
+                   super.make(node, childList);
+                   for (int count = childList.size() - 1; count >= 0; count--) {
+                       LayoutManager lm = (LayoutManager) childList.get(count);
+                       if (lm.generatesInlineAreas()) {
+                           LayoutManager blm = new BidiLayoutManager
+                            (node, (InlineLayoutManager) lm);
+                           lms.add(blm);
+                       } else {
+                           lms.add(lm);
+                       }
+                   }
+               }
+           }
+       }
+       
+       public static class InlineLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+             if (node.getChildNodes() != null) {
+                 lms.add(new InlineLayoutManager((InlineLevel) node));
+             }
+            }
+       }
+       
+       public static class FootnodeLayoutManagerMaker extends Maker {
+           public void make(FONode node, List lms) {
+            Inline citation = ((Footnote) node).getInlineFO();
+               if (citation != null) {
+                lms.add(new InlineLayoutManager(citation));
+            }
+           }           
+       }
+       
+       public static class InlineContainerLayoutManagerMaker extends Maker {
+           public void make(FONode node, List lms) {
+               ArrayList childList = new ArrayList();
+               super.make(node, childList);
+               lms.add(new ICLayoutManager((InlineContainer) node, childList));
+           }           
+       }
+       
+       public static class BasicLinkLayoutManagerMaker extends Maker {
+        public void make(FONode node, List lms) {
+            lms.add(new BasicLinkLayoutManager((BasicLink) node));
+        }
+    }
+       
+       public static class BlockLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+                lms.add(new BlockLayoutManager((Block) node));
+            }
+       }
+       
+       public static class LeaderLayoutManagerMaker extends Maker {
+        public void make(FONode node, List lms) {
+            lms.add(new LeaderLayoutManager((Leader) node));
+        }
+    }
+
+       public static class CharacterLayoutManagerMaker extends Maker {
+        public void make(FONode node, List lms) {
+            lms.add(new CharacterLayoutManager((Character) node));
+        }
+    }
+
+       public static class ExternalGraphicLayoutManagerMaker extends Maker {
+           public void make(FONode node, List lms) {
+            ExternalGraphic eg = (ExternalGraphic) node;
+            if (!eg.getSrc().equals("")) {
+                lms.add(new ExternalGraphicLayoutManager(eg));
+            }
+        }
+    }
+
+       public static class BlockContainerLayoutManagerMaker extends Maker {
+               public void make(FONode node, List lms) {
+               lms.add(new BlockContainerLayoutManager((BlockContainer) node));
+            }
+       }
+
+       public static class ListItemLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+             lms.add(new ListItemLayoutManager((ListItem) node));
+            }          
+       }
+
+       public static class ListBlockLayoutManagerMaker extends Maker {
+               public void make(FONode node, List lms) {
+                       lms.add(new ListBlockLayoutManager((ListBlock) node));
+               }
+       }
+
+       public static class InstreamForeignObjectLayoutManagerMaker extends Maker {
+               public void make(FONode node, List lms) {
+            lms.add(new InstreamForeignObjectLM((InstreamForeignObject) node));
+        }
+    }
+
+       public static class PageNumberLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+             lms.add(new PageNumberLayoutManager((PageNumber) node));
+            }          
+       }
+
+       public static class PageNumberCitationLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+               lms.add(new PageNumberCitationLayoutManager((PageNumberCitation) node));
+            }
+    }
+
+    public static class PageSequenceLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+             lms.add(new PageSequenceLayoutManager((PageSequence) node));
+         }
+    }
+
+       public static class TableLayoutManagerMaker extends Maker {
+               public void make(FONode node, List lms) {
+                       Table table = (Table) node;
+                       TableLayoutManager tlm = new TableLayoutManager(table);
+                       ArrayList columns = table.getColumns();
+                       if (columns != null) {
+                               ArrayList columnLMs = new ArrayList();
+                               ListIterator iter = columns.listIterator();
+                               while (iter.hasNext()) {
+                    columnLMs.add(new Column((TableColumn) node));
+                               }
+                               tlm.setColumns(columnLMs);
+                       }
+                       if (table.getTableHeader() != null) {
+                               tlm.setTableHeader(new Body(table.getTableHeader()));
+                       }
+                       if (table.getTableFooter() != null) {
+                               tlm.setTableFooter(new Body(table.getTableFooter()));
+                       }
+                       lms.add(tlm);
+               }
+    }
+               
+       public static class TableBodyLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+                lms.add(new Body((TableBody) node));
+            }
+
+       }
+       
+    public static class TableColumnLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+             lms.add(new Column((TableColumn) node));
+               }               
+       }
+
+       public static class TableRowLayoutManagerMaker extends Maker {
+           public void make(FONode node, List lms) {
+               lms.add(new Row((TableRow) node));
+           }
+       }
+
+       public static class TableCellLayoutManagerMaker extends Maker {
+           public void make(FONode node, List lms) {
+               lms.add(new Cell((TableCell) node));
+           }
+       }
+
+       public static class FlowLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+                lms.add(new FlowLayoutManager((Flow) node));
+            }
+       }
+
+       public static class StaticContentLayoutManagerMaker extends Maker {
+            public void make(FONode node, List lms) {
+                lms.add(new StaticContentLayoutManager((StaticContent) node));
+            }
+       }
+
+       public class WrapperLayoutManagerMaker extends Maker {
+           public void make(FONode node, List lms) {
+               Iterator baseIter;
+               baseIter = node.getChildNodes();
+               if (baseIter == null) {
+                return;
+            }
+               while (baseIter.hasNext()) {
+                   FONode child = (FONode) baseIter.next();
+                   makeLayoutManagers(child, lms);
+               }
+           }           
+       }
+
+}
index 74ceb07454fe02940b0a03bd2a30816d19be2400..2d5515e08e0f11f45afdfefda98930ebd44185db 100644 (file)
@@ -128,19 +128,34 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
      * This is the top level layout manager.
      * It is created by the PageSequence FO.
      *
-     * @param areaTree the area tree to add pages to
      * @param pageseq the page sequence fo
      */
-    public PageSequenceLayoutManager(AreaTreeHandler areaTreeHandler, PageSequence pageseq) {
+    public PageSequenceLayoutManager(PageSequence pageseq) {
         super(pageseq);
         fobj = pageseq;
-        this.areaTreeHandler = areaTreeHandler;
-        areaTreeModel = areaTreeHandler.getAreaTreeModel();
         if (fobj.getPageSequenceMaster() != null) {
             fobj.getPageSequenceMaster().reset();
         }
     }
 
+    /**
+     * Set the AreaTreeHandler
+     * @param areaTreeHandler the area tree handler to add pages to
+     */
+    public void setAreaTreeHandler(AreaTreeHandler areaTreeHandler) {
+        this.areaTreeHandler = areaTreeHandler;
+        areaTreeModel = areaTreeHandler.getAreaTreeModel();
+    }
+
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager
+     * @return the AreaTreeHandler object
+     */
+    public AreaTreeHandler getAreaTreeHandler() {
+        return areaTreeHandler;
+    }
+
+
     /**
      * Set the page counting for this page sequence.
      * This sets the initial page number and the page number formatter.
@@ -174,6 +189,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
 
         ContentLayoutManager clm = new ContentLayoutManager(title);
         clm.setUserAgent(foTitle.getUserAgent());
+        clm.setAreaTreeHandler(areaTreeHandler);
 
         // use special layout manager to add the inline areas
         // to the Title.
@@ -891,12 +907,14 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
      */
     private StaticContentLayoutManager getStaticContentLayoutManager(StaticContent sc) {
         StaticContentLayoutManager lm =
-                (StaticContentLayoutManager)staticContentLMs.get(sc.getFlowName());
-        if (lm != null) {
-            return lm;
+            (StaticContentLayoutManager)
+            staticContentLMs.get(sc.getFlowName());
+        if (lm == null) {
+            lm = (StaticContentLayoutManager)
+                getAreaTreeHandler().getLayoutManagerMaker().
+                makeLayoutManager(sc);
+            staticContentLMs.put(sc.getFlowName(), lm);
         }
-        lm = new StaticContentLayoutManager(sc);
-        staticContentLMs.put(sc.getFlowName(), lm);
         return lm;
     }
 }