You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2013/11/20 18:49:43 UTC

svn commit: r1543891 - in /xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop: fo/ fo/extensions/ fo/flow/ layoutmgr/

Author: vhennebert
Date: Wed Nov 20 17:49:42 2013
New Revision: 1543891

URL: http://svn.apache.org/r1543891
Log:
Removed obsolete BestFit and Alternative classes, and fox:fitting-strategy property
Patch by Seifeddine Dridi

Removed:
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/extensions/BestFit.java
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/Alternative.java
Modified:
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/Constants.java
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/FOPropertyMapping.java
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiCase.java
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiSwitch.java
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitLayoutUtils.java
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitPenalty.java
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/MultiSwitchLayoutManager.java
    xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java

Modified: xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/Constants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/Constants.java?rev=1543891&r1=1543890&r2=1543891&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/Constants.java (original)
+++ xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/Constants.java Wed Nov 20 17:49:42 2013
@@ -817,13 +817,10 @@ public interface Constants {
     int PR_X_HEADER_COLUMN = 290;
 
     /** Property constant */
-    int PR_X_FITTING_STRATEGY = 291;
-
-    /** Property constant */
-    int PR_X_AUTO_TOGGLE = 292;
+    int PR_X_AUTO_TOGGLE = 291;
 
     /** Number of property constants defined */
-    int PROPERTY_COUNT = 292;
+    int PROPERTY_COUNT = 291;
 
     // compound property constants
 

Modified: xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/FOPropertyMapping.java?rev=1543891&r1=1543890&r2=1543891&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/FOPropertyMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/FOPropertyMapping.java Wed Nov 20 17:49:42 2013
@@ -2617,12 +2617,6 @@ public final class FOPropertyMapping imp
         m.setDefault("");
         addPropertyMaker("fox:alt-text", m);
 
-        // fox:fitting-strategy, used only in fox:best-fit
-        m = new StringProperty.Maker(PR_X_FITTING_STRATEGY);
-        m.setInherited(false);
-        m.setDefault("first-fit");
-        addPropertyMaker("fox:fitting-strategy", m);
-
         // fox:auto-toggle, used only in fo:multi-switch
         m = new StringProperty.Maker(PR_X_AUTO_TOGGLE);
         m.setInherited(false);

Modified: xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiCase.java?rev=1543891&r1=1543890&r2=1543891&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiCase.java (original)
+++ xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiCase.java Wed Nov 20 17:49:42 2013
@@ -44,8 +44,6 @@ public class MultiCase extends FObj {
     //     private CommonAccessibility commonAccessibility;
     // End of property values
 
-    private static boolean notImplementedWarningGiven = false;
-
     /**
      * Base constructor
      *
@@ -53,12 +51,6 @@ public class MultiCase extends FObj {
      */
     public MultiCase(FONode parent) {
         super(parent);
-
-        if (!notImplementedWarningGiven) {
-            getFOValidationEventProducer().unimplementedFeature(this, getName(),
-                    getName(), getLocator());
-            notImplementedWarningGiven = true;
-        }
     }
 
     @Override
@@ -134,7 +126,7 @@ public class MultiCase extends FObj {
         return caseTitle;
     }
 
-    public boolean isActuated() {
+    public boolean hasToggle() {
         return multiCaseHandler != null;
     }
 

Modified: xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiSwitch.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiSwitch.java?rev=1543891&r1=1543890&r2=1543891&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiSwitch.java (original)
+++ xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/fo/flow/MultiSwitch.java Wed Nov 20 17:49:42 2013
@@ -38,7 +38,6 @@ public class MultiSwitch extends FObj {
     //     private CommonAccessibility commonAccessibility;
     // End of property values
 
-    private static boolean notImplementedWarningGiven;
     private FONode currentlyVisibleMultiCase;
     private String autoToggle;
     private String fittingStrategy;
@@ -50,12 +49,6 @@ public class MultiSwitch extends FObj {
      */
     public MultiSwitch(FONode parent) {
         super(parent);
-
-        if (!notImplementedWarningGiven) {
-            getFOValidationEventProducer().unimplementedFeature(this, getName(),
-                    getName(), getLocator());
-            notImplementedWarningGiven = true;
-        }
     }
 
     /** {@inheritDoc} */
@@ -63,7 +56,6 @@ public class MultiSwitch extends FObj {
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
         autoToggle = pList.get(PR_X_AUTO_TOGGLE).getString();
-        fittingStrategy = pList.get(PR_X_FITTING_STRATEGY).getString();
         // autoRestore = pList.get(PR_AUTO_RESTORE);
     }
 
@@ -85,7 +77,7 @@ public class MultiSwitch extends FObj {
             FONodeIterator nodeIter = getChildNodes();
             while (nodeIter.hasNext()) {
                 MultiCase multiCase = (MultiCase) nodeIter.next();
-                if (multiCase.isActuated()) {
+                if (multiCase.hasToggle()) {
                     multiCase.getHandler().filter(this);
                 }
             }

Modified: xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitLayoutUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitLayoutUtils.java?rev=1543891&r1=1543890&r2=1543891&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitLayoutUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitLayoutUtils.java Wed Nov 20 17:49:42 2013
@@ -21,8 +21,6 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.fop.layoutmgr.Alternative.FittingStrategy;
-
 /*
  * Utility class used in {@link MultiSwitchLayoutManager}
  * to handle  the <i>best-fit</i> property value if specified in {@link MultiSwitch}
@@ -38,13 +36,14 @@ public final class BestFitLayoutUtils {
         public BestFitPosition(LayoutManager lm) {
             super(lm);
         }
-
+        public BestFitPosition(LayoutManager lm, List<ListElement> knuthList) {
+            super(lm);
+            this.knuthList = knuthList;
+        }
         public List<Position> getPositionList() {
             List<Position> positions = new LinkedList<Position>();
             if (knuthList != null) {
-
                 SpaceResolver.performConditionalsNotification(knuthList, 0, knuthList.size() - 1, -1);
-
                 for (ListElement elem : knuthList) {
                     if (elem.getPosition() != null && elem.getLayoutManager() != null) {
                         positions.add(elem.getPosition());
@@ -53,50 +52,31 @@ public final class BestFitLayoutUtils {
             }
             return positions;
         }
-
         public void setKnuthList(List<ListElement> knuthList) {
             this.knuthList = knuthList;
         }
-
-        public List<ListElement> getKnuthList() {
-            return knuthList;
-        }
-
-    }
-
-    public static Alternative makeAlternative(List<ListElement> childList) {
-        // Add a zero penalty to make the SpaceResolver
-        // transform Space elements into Knuth glues.
-        childList.add(KnuthPenalty.DUMMY_ZERO_PENALTY);
-        SpaceResolver.resolveElementList(childList);
-        int contentLength = ElementListUtils.calcContentLength(childList);
-        return new Alternative(childList, contentLength);
     }
 
     public static List<ListElement> getKnuthList(LayoutManager lm,
-            List<List<ListElement>> childrenLists,
-            FittingStrategy strategy) {
+            List<List<ListElement>> childrenLists) {
+
         List<ListElement> knuthList = new LinkedList<ListElement>();
+
         Iterator<List<ListElement>> iter = childrenLists.iterator();
-        BestFitPenalty bestFitPenalty = new BestFitPenalty(strategy, new BestFitPosition(lm));
         while (iter.hasNext()) {
+
             List<ListElement> childList = iter.next();
-            bestFitPenalty.addAlternative(makeAlternative(childList));
+            SpaceResolver.resolveElementList(childList);
+            int contentLength = ElementListUtils.calcContentLength(childList);
+            BestFitPenalty bestFitPenalty =
+                    new BestFitPenalty(contentLength, childList,
+                    new BestFitPosition(lm));
+            knuthList.add(bestFitPenalty);
         }
-        // A penalty must always be preceded by a box
-        // to be considered as a valid breakpoint.
-        addKnuthPenalty(lm, knuthList, bestFitPenalty);
+        knuthList.add(new KnuthBox(0, new Position(lm), false));
         return knuthList;
     }
 
-    public static void addKnuthPenalty(LayoutManager lm, List<ListElement> list,
-            KnuthPenalty bestFitPenalty) {
-
-        list.add(0, new KnuthBox(0, new Position(lm), false));
-        list.add(bestFitPenalty);
-        list.add(new KnuthBox(0, new Position(lm), false));
-    }
-
     public static List<Position> getPositionList(LayoutManager lm, PositionIterator posIter) {
 
         // "unwrap" the NonLeafPositions stored in parentIter

Modified: xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitPenalty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitPenalty.java?rev=1543891&r1=1543890&r2=1543891&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitPenalty.java (original)
+++ xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/BestFitPenalty.java Wed Nov 20 17:49:42 2013
@@ -19,10 +19,8 @@
 
 package org.apache.fop.layoutmgr;
 
-import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.fop.layoutmgr.Alternative.FittingStrategy;
 import org.apache.fop.layoutmgr.BestFitLayoutUtils.BestFitPosition;
 
 /**
@@ -33,59 +31,24 @@ import org.apache.fop.layoutmgr.BestFitL
  */
 public class BestFitPenalty extends KnuthPenalty {
 
-    private final LinkedList<Alternative> alternatives;
-    private final FittingStrategy strategy;
-    public boolean canFit = true;
-    private int currentAltIndex;
-
-    public BestFitPenalty(FittingStrategy strategy, Position pos) {
-        super(0, 0, false, pos, false);
-        this.strategy = strategy;
-        alternatives = new LinkedList<Alternative>();
-    }
-
-    public void addAlternative(Alternative alternative) {
-        alternatives.add(alternative);
-    }
+    private final List<ListElement> knuthList;
+    public boolean ignorePenalty;
 
-    public List<Alternative> getAlternatives() {
-        return alternatives;
+    public BestFitPenalty(int width, List<ListElement> knuthList, Position pos) {
+        super(width, 0, false, pos, false);
+        this.knuthList = knuthList;
     }
 
-    public FittingStrategy getFittingStrategy() {
-        return strategy;
+    public void activateContent() {
+        BestFitPosition pos = getBestFitPosition();
+        pos.setKnuthList(knuthList);
     }
 
-    @Override
     public int getWidth() {
-        if (currentAltIndex == -1) {
+        if (ignorePenalty) {
             return 0;
         }
-        return alternatives.get(currentAltIndex).getLength();
-    }
-
-    public boolean hasMoreAlternatives() {
-        return currentAltIndex != -1;
-    }
-
-    public void considerNextAlternative() {
-        if (currentAltIndex < alternatives.size() - 1) {
-            currentAltIndex++;
-        } else {
-            currentAltIndex = -1;
-        }
-    }
-
-    @Override
-    public Position getPosition() {
-        if (currentAltIndex != -1) {
-            Position pos = super.getPosition();
-            if (alternatives.size() > 0) {
-                getBestFitPosition().setKnuthList(alternatives.get(currentAltIndex).getKnuthList());
-            }
-            return pos;
-        }
-        return null;
+        return super.getWidth();
     }
 
     public BestFitPosition getBestFitPosition() {
@@ -103,8 +66,8 @@ public class BestFitPenalty extends Knut
     public String toString() {
         String str = super.toString();
         StringBuffer buffer = new StringBuffer(64);
-        buffer.append(" number of alternatives = " + getAlternatives().size());
-        buffer.append(" fitting-strategy = " + strategy.getStrategyName());
+//        buffer.append(" number of alternatives = " + alternatives.size());
+//        buffer.append(" fitting-strategy = " + strategy.getStrategyName());
         return str + buffer.toString();
     }
 

Modified: xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/MultiSwitchLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/MultiSwitchLayoutManager.java?rev=1543891&r1=1543890&r2=1543891&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/MultiSwitchLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/MultiSwitchLayoutManager.java Wed Nov 20 17:49:42 2013
@@ -28,7 +28,6 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FONode.FONodeIterator;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.flow.MultiSwitch;
-import org.apache.fop.layoutmgr.Alternative.FittingStrategy;
 
 public class MultiSwitchLayoutManager extends BlockStackingLayoutManager {
 
@@ -56,7 +55,7 @@ public class MultiSwitchLayoutManager ex
             }
         }
         setFinished(true);
-        return BestFitLayoutUtils.getKnuthList(this, childrenLists, FittingStrategy.FIRST_FIT);
+        return BestFitLayoutUtils.getKnuthList(this, childrenLists);
     }
 
     @Override

Modified: xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=1543891&r1=1543890&r2=1543891&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/branches/Temp_WhitespaceManagement/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java Wed Nov 20 17:49:42 2013
@@ -149,9 +149,6 @@ class PageBreakingAlgorithm extends Brea
         /** Index of the last inserted element of the last inserted footnote. */
         public int footnoteElementIndex;
 
-        public boolean bestFitNode = false;
-        public boolean skipNode = false;
-
         public KnuthPageNode(int position,
                              int line, int fitness,
                              int totalWidth, int totalStretch, int totalShrink,
@@ -165,12 +162,6 @@ class PageBreakingAlgorithm extends Brea
             this.totalFootnotes = totalFootnotes;
             this.footnoteListIndex = footnoteListIndex;
             this.footnoteElementIndex = footnoteElementIndex;
-            if (getElement(position) instanceof BestFitPenalty) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Creating a KnuthPageNode for a BestFitPenalty.");
-                }
-                bestFitNode = true;
-            }
         }
 
     }
@@ -403,25 +394,7 @@ class PageBreakingAlgorithm extends Brea
     /** {@inheritDoc} */
     @Override
     protected int restartFrom(KnuthNode restartingNode, int currentIndex) {
-        if (getLastTooLong() != null) {
-            KnuthPageNode lastTooLong = (KnuthPageNode) getLastTooLong();
-            if (lastTooLong.skipNode) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Alternative does not fit in the current page. "
-                            + "Switching to the next one in the list");
-                }
-                int penaltyIndex = currentIndex;
-                // In case the paragraph has changed...
-                if (lastTooLong.previous.previous == null) {
-                    if (par.get(0) == KnuthPenalty.DUMMY_ZERO_PENALTY) {
-                        ++penaltyIndex;
-                    }
-                }
-                BestFitPenalty bestFitPenalty = (BestFitPenalty) getElement(penaltyIndex);
-                bestFitPenalty.considerNextAlternative();
-                restartingNode = restartingNode.previous;
-            }
-        }
+
         int returnValue = super.restartFrom(restartingNode, currentIndex);
         newFootnotes = false;
         if (footnotesPending) {
@@ -519,22 +492,6 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
-    protected void forceNode(KnuthNode node, int line, int elementIdx,
-            int difference, double r, double demerits, int fitnessClass,
-            int availableShrink, int availableStretch) {
-
-        super.forceNode(node, line, elementIdx, difference, r, demerits,
-                fitnessClass, availableShrink, availableStretch);
-
-        KnuthPageNode lastTooLong = (KnuthPageNode) getLastTooLong();
-        if (lastTooLong != null) {
-            if (lastTooLong.bestFitNode) {
-                lastTooLong.skipNode = true;
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override
     protected int computeDifference(KnuthNode activeNode, KnuthElement element,
                                     int elementIndex) {



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org