ASF Bugzilla – Attachment 23787 Details for
Bug 47347
[PATCH] auto table layout - yet another patch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
auto-table-layout.diff
auto-table-layout.diff (text/plain), 14.87 KB, created by
Achim Derigs
on 2009-06-10 07:21:24 UTC
(
hide
)
Description:
auto-table-layout.diff
Filename:
MIME Type:
Creator:
Achim Derigs
Created:
2009-06-10 07:21:24 UTC
Size:
14.87 KB
patch
obsolete
>Index: src/java/org/apache/fop/layoutmgr/LayoutManager.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/LayoutManager.java (revision 783305) >+++ src/java/org/apache/fop/layoutmgr/LayoutManager.java (working copy) >@@ -219,4 +219,9 @@ > * @return the same Position but with a position index > */ > Position notifyPos(Position pos); >+ >+ /** >+ * @return true if table-layout="auto" >+ */ >+ boolean isAutoLayout(); > } >Index: src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (revision 783305) >+++ src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (working copy) >@@ -645,6 +645,7 @@ > InlineLevelLayoutManager curLM; > List returnedList = null; > iLineWidth = context.getStackLimitIP().opt; >+ int ipd = 0; > > // convert all the text in a sequence of paragraphs made > // of KnuthBox, KnuthGlue and KnuthPenalty objects >@@ -693,6 +694,16 @@ > ListIterator iter = returnedList.listIterator(); > while (iter.hasNext()) { > KnuthSequence sequence = (KnuthSequence) iter.next(); >+ >+ if (isAutoLayout()) { >+ final ListIterator i = sequence.listIterator(); >+ >+ while (i.hasNext()) { >+ final KnuthElement element = (KnuthElement) i.next(); >+ ipd += element.getW(); >+ } >+ } >+ > // the sequence contains inline Knuth elements > if (sequence.isInlineSequence()) { > // look at the last element >@@ -763,6 +774,19 @@ > trace.append(" ]"); > } > } >+ >+ if (this.iLineWidth < ipd && isAutoLayout()) { >+ this.iLineWidth = ipd; >+ final MinOptMax stackLimitIP = context.getStackLimitIP(); >+ stackLimitIP.opt = ipd; >+ >+ if (stackLimitIP.max < ipd) { >+ stackLimitIP.max = ipd; >+ } >+ >+ context.setRefIPD(ipd); >+ } >+ > log.trace(trace); > } > >Index: src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (revision 783305) >+++ src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (working copy) >@@ -19,6 +19,7 @@ > > package org.apache.fop.layoutmgr.table; > >+import java.util.HashMap; > import java.util.Iterator; > import java.util.LinkedList; > import java.util.List; >@@ -32,8 +33,10 @@ > import org.apache.fop.fo.Constants; > import org.apache.fop.fo.FObj; > import org.apache.fop.fo.flow.table.EffRow; >+import org.apache.fop.fo.flow.table.GridUnit; > import org.apache.fop.fo.flow.table.PrimaryGridUnit; > import org.apache.fop.fo.flow.table.Table; >+import org.apache.fop.fo.flow.table.TableColumn; > import org.apache.fop.fo.flow.table.TablePart; > import org.apache.fop.layoutmgr.BlockLevelLayoutManager; > import org.apache.fop.layoutmgr.BreakElement; >@@ -58,7 +61,8 @@ > /** Logger **/ > private static Log log = LogFactory.getLog(TableContentLayoutManager.class); > >- private TableLayoutManager tableLM; >+ private final TableLayoutManager tableLM; >+ private final Map baseLength = new HashMap(); > private TableRowIterator bodyIter; > private TableRowIterator headerIter; > private TableRowIterator footerIter; >@@ -128,6 +132,72 @@ > return this.footerList; > } > >+ final Number getBaseLength(final FObj key) { >+ return (Number) this.baseLength.get(key); >+ } >+ >+ private boolean setBaseLength(final PrimaryGridUnit primary) { >+ final Table table = this.tableLM.getTable(); >+ final int index = primary.getColIndex(); >+ final TableColumn key = table.getColumn(index); >+ int spanWidth = key.getColumnWidth().getValue(this.tableLM); >+ final int n = index + primary.getCell().getNumberColumnsSpanned(); >+ >+ for (int i = index + 1; i < n; i++) { >+ final TableColumn column = table.getColumn(i); >+ spanWidth += column.getColumnWidth().getValue(this.tableLM); >+ } >+ >+ final Number length = getBaseLength(key); >+ final int ipd = primary.getCellLM().getRefIPD(); >+ >+ if (spanWidth == 0) { >+ if (length == null) { >+ this.baseLength.put(key, new Integer(ipd)); >+ } >+ } else if (spanWidth < ipd && index == n - 1) { >+ return length == this.baseLength.put(key, new Integer(ipd)); >+ } >+ >+ return false; >+ } >+ >+ private boolean setBaseLength(final TableContentPosition position) { >+ boolean done = false; >+ final EffRow row = position.getRow(); >+ final Iterator grid = row.getGridUnits().iterator(); >+ >+ while (grid.hasNext()) { >+ final GridUnit unit = (GridUnit) grid.next(); >+ >+ if (unit instanceof PrimaryGridUnit) { >+ done = setBaseLength((PrimaryGridUnit) unit) || done; >+ } >+ } >+ >+ return done; >+ } >+ >+ private boolean setBaseLength(final Iterator content) { >+ boolean done = false; >+ >+ while (content.hasNext()) { >+ final ListElement element = (ListElement) content.next(); >+ final Position position = element.getPosition(); >+ >+ if (position instanceof TableContentPosition) { >+ done = setBaseLength((TableContentPosition) position) || done; >+ } >+ } >+ >+ return done; >+ } >+ >+ private boolean setBaseLength(final List content) { >+ final Table table = this.tableLM.getTable(); >+ return table.isAutoLayout() && setBaseLength(content.iterator()); >+ } >+ > /** {@inheritDoc} */ > public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { > if (log.isDebugEnabled()) { >@@ -139,6 +209,14 @@ > if (headerIter != null && headerList == null) { > this.headerList = getKnuthElementsForRowIterator( > headerIter, context, alignment, TableRowIterator.HEADER); >+ >+ if (setBaseLength(this.headerList)) { >+ final Table table = this.tableLM.getTable(); >+ this.headerIter = new TableRowIterator(table, TableRowIterator.HEADER); >+ this.headerList = null; >+ return getNextKnuthElements(context, alignment); >+ } >+ > this.headerNetHeight > = ElementListUtils.calcContentLength(this.headerList); > if (log.isDebugEnabled()) { >@@ -159,6 +237,20 @@ > if (footerIter != null && footerList == null) { > this.footerList = getKnuthElementsForRowIterator( > footerIter, context, alignment, TableRowIterator.FOOTER); >+ >+ if (setBaseLength(this.footerList)) { >+ final Table table = this.tableLM.getTable(); >+ >+ if (this.headerIter != null) { >+ this.headerIter = new TableRowIterator(table, TableRowIterator.HEADER); >+ this.headerList = null; >+ } >+ >+ this.footerIter = new TableRowIterator(table, TableRowIterator.FOOTER); >+ this.footerList = null; >+ return getNextKnuthElements(context, alignment); >+ } >+ > this.footerNetHeight > = ElementListUtils.calcContentLength(this.footerList); > if (log.isDebugEnabled()) { >@@ -173,6 +265,24 @@ > } > LinkedList returnList = getKnuthElementsForRowIterator( > bodyIter, context, alignment, TableRowIterator.BODY); >+ >+ if (setBaseLength(returnList)) { >+ final Table table = this.tableLM.getTable(); >+ >+ if (this.headerIter != null) { >+ this.headerIter = new TableRowIterator(table, TableRowIterator.HEADER); >+ this.headerList = null; >+ } >+ >+ if (this.footerIter != null) { >+ this.footerIter = new TableRowIterator(table, TableRowIterator.FOOTER); >+ this.footerList = null; >+ } >+ >+ this.bodyIter = new TableRowIterator(table, TableRowIterator.BODY); >+ return getNextKnuthElements(context, alignment); >+ } >+ > if (headerAsFirst != null) { > int insertionPoint = 0; > if (returnList.size() > 0 && ((ListElement)returnList.getFirst()).isForcedBreak()) { >Index: src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (revision 783305) >+++ src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (working copy) >@@ -66,7 +66,7 @@ > */ > private static Log log = LogFactory.getLog(TableCellLayoutManager.class); > >- private PrimaryGridUnit primaryGridUnit; >+ private final PrimaryGridUnit primaryGridUnit; > > private Block curBlockArea; > >@@ -124,6 +124,23 @@ > return startIndent + endIndent; > } > >+ final int getRefIPD() { >+ return this.referenceIPD; >+ } >+ >+ /** {@inheritDoc} */ >+ public final boolean isAutoLayout() { >+ final Table table = getTable(); >+ >+ if (table.isAutoLayout()) { >+ final int index = this.primaryGridUnit.getColIndex(); >+ final TableColumn column = table.getColumn(index); >+ return column.isAutoLayout(); >+ } >+ >+ return false; >+ } >+ > /** > * {@inheritDoc} > */ >@@ -149,6 +166,13 @@ > > // get elements from curLM > returnedList = curLM.getNextKnuthElements(childLC, alignment); >+ final int ipd = childLC.getRefIPD() + getIPIndents(); >+ >+ if (getRefIPD() < ipd && isAutoLayout()) { >+ this.referenceIPD = ipd; >+ this.cellIPD = getRefIPD() - getIPIndents(); >+ } >+ > if (childLC.isKeepWithNextPending()) { > log.debug("child LM signals pending keep with next"); > } >Index: src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (revision 783305) >+++ src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (working copy) >@@ -464,6 +464,11 @@ > return KeepUtil.getCombinedBlockLevelKeepStrength(getTable().getKeepWithPrevious()); > } > >+ /** {@inheritDoc} */ >+ public final boolean isAutoLayout() { >+ return getTable().isAutoLayout(); >+ } >+ > // --------- Property Resolution related functions --------- // > > /** >@@ -476,6 +481,13 @@ > case LengthBase.CONTAINING_BLOCK_WIDTH: > return getContentAreaIPD(); > case LengthBase.TABLE_UNITS: >+ if (this.contentLM != null && isAutoLayout()) { >+ if (((TableColumn) fobj).isAutoLayout()) { >+ final Number length = this.contentLM.getBaseLength(fobj); >+ return length == null ? 0 : length.intValue(); >+ } >+ } >+ > return (int) this.tableUnit; > default: > log.error("Unknown base type for LengthBase."); >Index: src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (revision 783305) >+++ src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (working copy) >@@ -208,7 +208,7 @@ > */ > protected int updateContentAreaIPDwithOverconstrainedAdjust() { > int ipd = referenceIPD - (startIndent + endIndent); >- if (ipd < 0) { >+ if (ipd < 0 && !isAutoLayout()) { > //5.3.4, XSL 1.0, Overconstrained Geometry > log.debug("Adjusting end-indent based on overconstrained geometry rules for " + fobj); > BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( >@@ -309,6 +309,20 @@ > > // get elements from curLM > returnedList = curLM.getNextKnuthElements(childLC, alignment); >+ final int ipd = childLC.getRefIPD(); >+ >+ if (curLM instanceof LineLayoutManager) { >+ if (getContentAreaIPD() < ipd && isAutoLayout()) { >+ this.referenceIPD = this.startIndent + ipd + this.endIndent; >+ updateContentAreaIPDwithOverconstrainedAdjust(); >+ context.setRefIPD(this.referenceIPD); >+ } >+ } else if (this.referenceIPD < ipd && isAutoLayout()) { >+ this.referenceIPD = ipd; >+ updateContentAreaIPDwithOverconstrainedAdjust(); >+ context.setRefIPD(this.referenceIPD); >+ } >+ > if (contentList.isEmpty() && childLC.isKeepWithPreviousPending()) { > //Propagate keep-with-previous up from the first child > context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending()); >Index: src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java (revision 783305) >+++ src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java (working copy) >@@ -253,4 +253,9 @@ > return fobj; > } > >+ /** {@inheritDoc} */ >+ public boolean isAutoLayout() { >+ final LayoutManager parent = getParent(); >+ return parent == null ? false : parent.isAutoLayout(); >+ } > } >Index: src/java/org/apache/fop/fo/flow/table/TableColumn.java >=================================================================== >--- src/java/org/apache/fop/fo/flow/table/TableColumn.java (revision 783305) >+++ src/java/org/apache/fop/fo/flow/table/TableColumn.java (working copy) >@@ -263,4 +263,7 @@ > this.pList = null; > } > >+ public final boolean isAutoLayout() { >+ return getColumnWidth() instanceof TableColLength; >+ } > } >Index: src/java/org/apache/fop/fo/flow/table/Table.java >=================================================================== >--- src/java/org/apache/fop/fo/flow/table/Table.java (revision 783305) >+++ src/java/org/apache/fop/fo/flow/table/Table.java (working copy) >@@ -137,10 +137,6 @@ > eventProducer.nonAutoBPDOnTable(this, getLocator()); > // Anyway, the bpd of a table is not used by the layout code > } >- if (tableLayout == EN_AUTO) { >- getFOValidationEventProducer().unimplementedFeature(this, getName(), >- "table-layout=\"auto\"", getLocator()); >- } > if (!isSeparateBorderModel() > && getCommonBorderPaddingBackground().hasPadding( > ValidationPercentBaseContext.getPseudoContext())) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47347
: 23787