aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/layoutmgr/table
diff options
context:
space:
mode:
authorGlenn Adams <gadams@apache.org>2012-02-26 02:29:01 +0000
committerGlenn Adams <gadams@apache.org>2012-02-26 02:29:01 +0000
commitd6d8e57b17eb2e36631115517afa003ad3afa1a1 (patch)
treebf355ee4643080bf13b8f9fa5a1b14002e968561 /src/java/org/apache/fop/layoutmgr/table
parentfa6dc48793a4eb7476282141c1314f1198371a67 (diff)
downloadxmlgraphics-fop-d6d8e57b17eb2e36631115517afa003ad3afa1a1.tar.gz
xmlgraphics-fop-d6d8e57b17eb2e36631115517afa003ad3afa1a1.zip
apply complex scripts patch
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1293736 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr/table')
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
index c1fc19050..aaccbd0d3 100644
--- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
+++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
@@ -33,6 +33,9 @@ import org.apache.fop.fo.expr.RelativeNumericProperty;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableColumn;
import org.apache.fop.fo.properties.TableColLength;
+import org.apache.fop.traits.Direction;
+import org.apache.fop.traits.WritingModeTraits;
+import org.apache.fop.traits.WritingModeTraitsGetter;
/**
* Class holding a number of columns making up the column setup of a row.
@@ -43,6 +46,7 @@ public class ColumnSetup {
private static Log log = LogFactory.getLog(ColumnSetup.class);
private Table table;
+ private WritingModeTraitsGetter wmTraits;
private List columns = new java.util.ArrayList();
private List colWidths = new java.util.ArrayList();
@@ -53,7 +57,9 @@ public class ColumnSetup {
* @param table the table to construct this column setup for
*/
public ColumnSetup(Table table) {
+ assert table != null;
this.table = table;
+ this.wmTraits = WritingModeTraits.getWritingModeTraitsGetter ( table );
prepareColumns();
initializeColumnWidths();
}
@@ -232,11 +238,47 @@ public class ColumnSetup {
}
/**
+ * Determine the X offset of the indicated column, where this
+ * offset denotes the left edge of the column irrespective of writing
+ * mode. If writing mode's column progression direction is right-to-left,
+ * then the first column is the right-most column and the last column is
+ * the left-most column; otherwise, the first column is the left-most
+ * column.
* @param col column index (1 is first column)
* @param context the context for percentage based calculations
* @return the X offset of the requested column
*/
public int getXOffset(int col, PercentBaseContext context) {
+ // TODO handle vertical WMs [GA]
+ if ( (wmTraits != null) && (wmTraits.getColumnProgressionDirection() == Direction.RL) ) {
+ return getXOffsetRTL(col, context);
+ } else {
+ return getXOffsetLTR(col, context);
+ }
+ }
+
+ /*
+ * Determine x offset by summing widths of columns to left of specified
+ * column; i.e., those columns whose column numbers are greater than the
+ * specified column number.
+ */
+ private int getXOffsetRTL(int col, PercentBaseContext context) {
+ int xoffset = 0;
+ for (int i = col, nc = colWidths.size(); ++i < nc;) {
+ int effCol = i;
+ if (colWidths.get(effCol) != null) {
+ xoffset += ((Length) colWidths.get(effCol)).getValue(context);
+ }
+ }
+ return xoffset;
+ }
+
+ /*
+ * Determine x offset by summing widths of columns to left of specified
+ * column; i.e., those columns whose column numbers are less than the
+ * specified column number.
+ */
+ private int getXOffsetLTR(int col, PercentBaseContext context) {
int xoffset = 0;
for (int i = col; --i >= 0;) {
int effCol;