diff options
author | William Victor Mote <vmote@apache.org> | 2003-09-18 17:11:51 +0000 |
---|---|---|
committer | William Victor Mote <vmote@apache.org> | 2003-09-18 17:11:51 +0000 |
commit | ccec697126aed2004e7566c599a243701d0cc41a (patch) | |
tree | e31382f5cb2d98099a2de7a1f54c2056445fb9e3 | |
parent | 1519516c352043282afe61f8b425cff5788f40d1 (diff) | |
download | xmlgraphics-fop-ccec697126aed2004e7566c599a243701d0cc41a.tar.gz xmlgraphics-fop-ccec697126aed2004e7566c599a243701d0cc41a.zip |
style changes only
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196922 13f79535-47bb-0310-9956-ffa450edef68
5 files changed, 475 insertions, 467 deletions
diff --git a/src/java/org/apache/fop/rtf/renderer/BuilderContext.java b/src/java/org/apache/fop/rtf/renderer/BuilderContext.java index 00e41c524..6d530b274 100644 --- a/src/java/org/apache/fop/rtf/renderer/BuilderContext.java +++ b/src/java/org/apache/fop/rtf/renderer/BuilderContext.java @@ -1,4 +1,5 @@ /* + * $Id$ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ @@ -50,7 +51,8 @@ package org.apache.fop.rtf.renderer; import java.util.Stack; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import org.apache.fop.rtf.rtflib.rtfdoc.IRtfOptions; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfContainer; /** A BuilderContext holds context information when building an RTF document @@ -64,136 +66,133 @@ import org.apache.fop.rtf.rtflib.rtfdoc.*; */ -class BuilderContext -{ - /** stack of RtfContainers */ - private final Stack m_containers = new Stack(); - - /** stack of TableContexts */ - private final Stack m_tableContexts = new Stack(); - - /** stack of IBuilders */ - private final Stack m_builders = new Stack(); - - /** Rtf options */ - IRtfOptions m_options; - - BuilderContext(IRtfOptions rtfOptions) - { - m_options = rtfOptions; - } - - /** find first object of given class from top of stack s - * @return null if not found - */ - private Object getObjectFromStack(Stack s,Class desiredClass) - { - Object result = null; - final Stack copy = (Stack)s.clone(); - while(!copy.isEmpty()) { - final Object o = copy.pop(); - if(desiredClass.isAssignableFrom(o.getClass())) { - result = o; - break; - } - } - return result; - } - - /* find the "nearest" IBuilder of given class / - Object getBuilder(Class builderClass,boolean required) - throws Exception - { - final IBuilder result = (IBuilder)getObjectFromStack(m_builders,builderClass); - if(result == null && required) { - throw new Exception( - "IBuilder of class '" + builderClass.getName() + "' not found on builders stack" - ); - } - return result; - }*/ - - /** find the "nearest" container that implements the given interface on our stack - * @param required if true, ConverterException is thrown if no container found - * @param forWhichBuilder used in error message if container not found - */ - RtfContainer getContainer(Class containerClass,boolean required,Object /*IBuilder*/ forWhichBuilder) throws Exception - { - // TODO what to do if the desired container is not at the top of the stack? - // close top-of-stack container? - final RtfContainer result = (RtfContainer)getObjectFromStack(m_containers,containerClass); - - if(result == null && required) { - throw new Exception( - "No RtfContainer of class '" + containerClass.getName() - + "' available for '" + forWhichBuilder.getClass().getName() + "' builder" - ); - } - - return result; - } - - /** push an RtfContainer on our stack */ - void pushContainer(RtfContainer c) - { - m_containers.push(c); - } - - /** in some cases an RtfContainer must be replaced by another one on the stack. - * this happens when handling nested fo:blocks for example: after handling a nested block - * the enclosing block must switch to a new paragraph container to handle what follows the nested block. - * TODO: what happens to elements that are "more on top" than oldC on the stack? shouldn't they be closed - * or something? - */ - void replaceContainer(RtfContainer oldC,RtfContainer newC) - throws Exception - { - // treating the Stack as a Vector allows such manipulations (yes, I hear you screaming ;-) - final int index = m_containers.indexOf(oldC); - if(index < 0) throw new Exception("container to replace not found:" + oldC); - m_containers.setElementAt(newC,index); - } - - /** pop the topmost RtfContainer from our stack */ - void popContainer() - { - m_containers.pop(); - } - - /* push an IBuilder to our stack / - void pushBuilder(IBuilder b) - { - m_builders.push(b); - }*/ - - /** pop the topmost IBuilder from our stack and return previous builder on stack - * @return null if builders stack is empty - - IBuilder popBuilderAndGetPreviousOne() - { - IBuilder result = null; - m_builders.pop(); - if(!m_builders.isEmpty()) { - result = (IBuilder)m_builders.peek(); - } - return result; - } +class BuilderContext { + /** stack of RtfContainers */ + private final Stack m_containers = new Stack(); + + /** stack of TableContexts */ + private final Stack m_tableContexts = new Stack(); + + /** stack of IBuilders */ + private final Stack m_builders = new Stack(); + + /** Rtf options */ + IRtfOptions m_options; + + BuilderContext(IRtfOptions rtfOptions) { + m_options = rtfOptions; + } + + /** find first object of given class from top of stack s + * @return null if not found + */ + private Object getObjectFromStack(Stack s, Class desiredClass) { + Object result = null; + final Stack copy = (Stack)s.clone(); + while (!copy.isEmpty()) { + final Object o = copy.pop(); + if (desiredClass.isAssignableFrom(o.getClass())) { + result = o; + break; + } + } + return result; + } + + /* find the "nearest" IBuilder of given class / + Object getBuilder(Class builderClass,boolean required) + throws Exception + { + final IBuilder result = (IBuilder)getObjectFromStack(m_builders,builderClass); + if(result == null && required) { + throw new Exception( + "IBuilder of class '" + builderClass.getName() + "' not found on builders stack" + ); + } + return result; + }*/ + + /** find the "nearest" container that implements the given interface on our stack + * @param required if true, ConverterException is thrown if no container found + * @param forWhichBuilder used in error message if container not found + */ + RtfContainer getContainer(Class containerClass, boolean required, + Object /*IBuilder*/ forWhichBuilder) throws Exception { + // TODO what to do if the desired container is not at the top of the stack? + // close top-of-stack container? + final RtfContainer result = (RtfContainer)getObjectFromStack(m_containers, + containerClass); + + if (result == null && required) { + throw new Exception( + "No RtfContainer of class '" + containerClass.getName() + + "' available for '" + forWhichBuilder.getClass().getName() + "' builder" + ); + } + + return result; + } + + /** push an RtfContainer on our stack */ + void pushContainer(RtfContainer c) { + m_containers.push(c); + } + + /** + * In some cases an RtfContainer must be replaced by another one on the + * stack. This happens when handling nested fo:blocks for example: after + * handling a nested block the enclosing block must switch to a new + * paragraph container to handle what follows the nested block. + * TODO: what happens to elements that are "more on top" than oldC on the + * stack? shouldn't they be closed or something? + */ + void replaceContainer(RtfContainer oldC, RtfContainer newC) + throws Exception { + // treating the Stack as a Vector allows such manipulations (yes, I hear you screaming ;-) + final int index = m_containers.indexOf(oldC); + if (index < 0) { + throw new Exception("container to replace not found:" + oldC); + } + m_containers.setElementAt(newC, index); + } + + /** pop the topmost RtfContainer from our stack */ + void popContainer() { + m_containers.pop(); + } + + /* push an IBuilder to our stack / + void pushBuilder(IBuilder b) + { + m_builders.push(b); + }*/ + + /** pop the topmost IBuilder from our stack and return previous builder on stack + * @return null if builders stack is empty + + IBuilder popBuilderAndGetPreviousOne() + { + IBuilder result = null; + m_builders.pop(); + if(!m_builders.isEmpty()) { + result = (IBuilder)m_builders.peek(); + } + return result; + } */ - /** return the current TableContext */ - TableContext getTableContext() - { - return (TableContext)m_tableContexts.peek(); - } - - /** push a TableContext to our stack */ - void pushTableContext(TableContext tc) - { - m_tableContexts.push(tc); - } - - /** pop a TableContext from our stack */ - void popTableContext() - { - m_tableContexts.pop(); - } + /** return the current TableContext */ + TableContext getTableContext() { + return (TableContext)m_tableContexts.peek(); + } + + /** push a TableContext to our stack */ + void pushTableContext(TableContext tc) { + m_tableContexts.push(tc); + } + + /** pop a TableContext from our stack */ + void popTableContext() { + m_tableContexts.pop(); + } + }
\ No newline at end of file diff --git a/src/java/org/apache/fop/rtf/renderer/FoUnitsConverter.java b/src/java/org/apache/fop/rtf/renderer/FoUnitsConverter.java index 99bec8fd4..5451c71ca 100644 --- a/src/java/org/apache/fop/rtf/renderer/FoUnitsConverter.java +++ b/src/java/org/apache/fop/rtf/renderer/FoUnitsConverter.java @@ -1,4 +1,5 @@ /* + * $Id$ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ @@ -49,7 +50,8 @@ */ package org.apache.fop.rtf.renderer; -import java.util.*; +import java.util.Map; +import java.util.HashMap; //FOP import org.apache.fop.apps.FOPException; @@ -65,8 +67,7 @@ import org.apache.fop.apps.FOPException; * for the JFOR project and is now integrated into FOP. */ -class FoUnitsConverter -{ +class FoUnitsConverter { private static final FoUnitsConverter m_instance = new FoUnitsConverter(); /** points to twips: 1 twip is 1/20 of a point */ @@ -81,41 +82,38 @@ class FoUnitsConverter /** conversion factors keyed by xsl:fo units names */ private static final Map m_twipFactors = new HashMap(); static { - m_twipFactors.put("mm",new Float(MM_TO_TWIPS)); - m_twipFactors.put("cm",new Float(CM_TO_TWIPS)); - m_twipFactors.put("pt",new Float(POINT_TO_TWIPS)); - m_twipFactors.put("in",new Float(IN_TO_TWIPS)); + m_twipFactors.put("mm", new Float(MM_TO_TWIPS)); + m_twipFactors.put("cm", new Float(CM_TO_TWIPS)); + m_twipFactors.put("pt", new Float(POINT_TO_TWIPS)); + m_twipFactors.put("in", new Float(IN_TO_TWIPS)); } /** singleton pattern */ - private FoUnitsConverter() - { + private FoUnitsConverter() { } /** singleton pattern */ - static FoUnitsConverter getInstance() - { + static FoUnitsConverter getInstance() { return m_instance; } /** convert given value to RTF units * @param foValue a value like "12mm" * TODO: tested with "mm" units only, needs work to comply with FO spec - * Why does it search for period instead of simply breaking last two + * Why does it search for period instead of simply breaking last two * Characters into another units string? - Chris */ float convertToTwips(String foValue) - throws FOPException - { + throws FOPException { foValue = foValue.trim(); // break value into number and units final StringBuffer number = new StringBuffer(); final StringBuffer units = new StringBuffer(); - for(int i=0; i < foValue.length(); i++) { + for (int i = 0; i < foValue.length(); i++) { final char c = foValue.charAt(i); - if(Character.isDigit(c) || c == '.') { + if (Character.isDigit(c) || c == '.') { number.append(c); } else { // found the end of the digits @@ -124,29 +122,31 @@ class FoUnitsConverter } } - return numberToTwips(number.toString(),units.toString()); + return numberToTwips(number.toString(), units.toString()); } /** convert given value to twips according to given units */ - private float numberToTwips(String number,String units) - throws FOPException - { + private float numberToTwips(String number, String units) + throws FOPException { float result = 0; // convert number to integer try { - if(number != null && number.trim().length() > 0) { + if (number != null && number.trim().length() > 0) { result = Float.valueOf(number).floatValue(); } - } catch(Exception e) { - throw new FOPException("number format error: cannot convert '" + number + "' to float value"); + } catch (Exception e) { + throw new FOPException("number format error: cannot convert '" + + number + "' to float value"); } // find conversion factor - if(units != null && units.trim().length() > 0) { + if (units != null && units.trim().length() > 0) { final Float factor = (Float)m_twipFactors.get(units.toLowerCase()); - if(factor == null) throw new FOPException("conversion factor not found for '" + units + "' units"); + if (factor == null) { + throw new FOPException("conversion factor not found for '" + units + "' units"); + } result *= factor.floatValue(); } @@ -154,20 +154,19 @@ class FoUnitsConverter } /** convert a font size given in points like "12pt" */ - int convertFontSize(String size) - throws FOPException - { + int convertFontSize(String size) throws FOPException { size = size.trim(); final String FONT_SUFFIX = "pt"; - if(!size.endsWith(FONT_SUFFIX)) { - throw new FOPException("Invalid font size '" + size + "', must end with '" + FONT_SUFFIX + "'"); + if (!size.endsWith(FONT_SUFFIX)) { + throw new FOPException("Invalid font size '" + size + "', must end with '" + + FONT_SUFFIX + "'"); } float result = 0; - size = size.substring(0,size.length() - FONT_SUFFIX.length()); + size = size.substring(0, size.length() - FONT_SUFFIX.length()); try { result = (Float.valueOf(size).floatValue()); - } catch(Exception e) { + } catch (Exception e) { throw new FOPException("Invalid font size value '" + size + "'"); } diff --git a/src/java/org/apache/fop/rtf/renderer/RTFHandler.java b/src/java/org/apache/fop/rtf/renderer/RTFHandler.java index cb38defab..c900aad06 100644 --- a/src/java/org/apache/fop/rtf/renderer/RTFHandler.java +++ b/src/java/org/apache/fop/rtf/renderer/RTFHandler.java @@ -103,12 +103,12 @@ public class RTFHandler extends FOInputHandler { private RtfFile rtfFile; private final OutputStream os; - private final Logger log=new ConsoleLogger(); + private final Logger log = new ConsoleLogger(); private RtfSection sect; private RtfDocumentArea docArea; private RtfParagraph para; private boolean warned = false; - private BuilderContext m_context=new BuilderContext(null); + private BuilderContext m_context = new BuilderContext(null); private static final String ALPHA_WARNING = "WARNING: RTF renderer is " + "veryveryalpha at this time, see class org.apache.fop.rtf.renderer.RTFHandler"; @@ -205,7 +205,9 @@ public class RTFHandler extends FOInputHandler { attrBlockFontSize(bl, rtfAttr); attrBlockFontWeight(bl, rtfAttr); - IRtfParagraphContainer pc=(IRtfParagraphContainer)m_context.getContainer(IRtfParagraphContainer.class,true,null); + IRtfParagraphContainer pc = + (IRtfParagraphContainer)m_context.getContainer + (IRtfParagraphContainer.class, true, null); para = pc.newParagraph(rtfAttr); m_context.pushContainer(para); @@ -213,9 +215,7 @@ public class RTFHandler extends FOInputHandler { // FIXME could we throw Exception in all FOInputHandler events? log.error("startBlock: " + ioe.getMessage()); throw new Error("IOException: " + ioe); - } - catch(Exception e) - { + } catch (Exception e) { log.error("startBlock: " + e.getMessage()); throw new Error("Exception: " + e); } @@ -235,15 +235,14 @@ public class RTFHandler extends FOInputHandler { public void startTable(Table tbl) { // create an RtfTable in the current table container TableContext tableContext = new TableContext(m_context); - RtfAttributes atts=new RtfAttributes(); + RtfAttributes atts = new RtfAttributes(); - try - { - final IRtfTableContainer tc = (IRtfTableContainer)m_context.getContainer(IRtfTableContainer.class,true,null); + try { + final IRtfTableContainer tc = + (IRtfTableContainer)m_context.getContainer(IRtfTableContainer.class, + true, null); m_context.pushContainer(tc.newTable(atts, tableContext)); - } - catch(Exception e) - { + } catch (Exception e) { log.error("startTable:" + e.getMessage()); throw new Error(e.getMessage()); } @@ -265,14 +264,11 @@ public class RTFHandler extends FOInputHandler { */ public void startColumn(TableColumn tc) { - try - { - Integer iWidth=new Integer(tc.getColumnWidth()/1000); - m_context.getTableContext().setNextColumnWidth(iWidth.toString()+"pt"); - m_context.getTableContext().setNextColumnRowSpanning(new Integer(0),null); - } - catch(Exception e) - { + try { + Integer iWidth = new Integer(tc.getColumnWidth() / 1000); + m_context.getTableContext().setNextColumnWidth(iWidth.toString() + "pt"); + m_context.getTableContext().setNextColumnRowSpanning(new Integer(0), null); + } catch (Exception e) { log.error("startColumn: " + e.getMessage()); throw new Error(e.getMessage()); } @@ -284,7 +280,7 @@ public class RTFHandler extends FOInputHandler { * @param th TableColumn that is ending; */ - public void endColumn(TableColumn tc){ + public void endColumn(TableColumn tc) { } /** @@ -315,15 +311,13 @@ public class RTFHandler extends FOInputHandler { * @see org.apache.fop.fo.FOInputHandler#startBody(TableBody) */ public void startBody(TableBody tb) { - try - { - RtfAttributes atts=TableAttributesConverter.convertRowAttributes (tb.properties, null, null); + try { + RtfAttributes atts = TableAttributesConverter.convertRowAttributes (tb.properties, + null, null); - RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class,true,this); + RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class, true, this); tbl.setHeaderAttribs(atts); - } - catch(Exception e) - { + } catch (Exception e) { log.error("startBody: " + e.getMessage()); throw new Error(e.getMessage()); } @@ -333,13 +327,10 @@ public class RTFHandler extends FOInputHandler { * @see org.apache.fop.fo.FOInputHandler#endBody(TableBody) */ public void endBody(TableBody tb) { - try - { - RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class,true,this); - tbl.setHeaderAttribs( null ); - } - catch(Exception e) - { + try { + RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class, true, this); + tbl.setHeaderAttribs(null); + } catch (Exception e) { log.error("endBody: " + e.getMessage()); throw new Error(e.getMessage()); } @@ -349,22 +340,21 @@ public class RTFHandler extends FOInputHandler { * @see org.apache.fop.fo.FOInputHandler#startRow(TableRow) */ public void startRow(TableRow tr) { - try - { + try { // create an RtfTableRow in the current RtfTable - final RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class,true,null); + final RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class, + true, null); RtfAttributes tblAttribs = tbl.getRtfAttributes(); RtfAttributes tblRowAttribs = new RtfAttributes(); - RtfAttributes atts=TableAttributesConverter.convertRowAttributes(tr.properties,null,tbl.getHeaderAttribs()); + RtfAttributes atts = TableAttributesConverter.convertRowAttributes(tr.properties, + null, tbl.getHeaderAttribs()); - m_context.pushContainer(tbl.newTableRow( atts )); + m_context.pushContainer(tbl.newTableRow(atts)); // reset column iteration index to correctly access column widths m_context.getTableContext().selectFirstColumn(); - } - catch(Exception e) - { + } catch (Exception e) { log.error("startRow: " + e.getMessage()); throw new Error(e.getMessage()); } @@ -382,46 +372,44 @@ public class RTFHandler extends FOInputHandler { * @see org.apache.fop.fo.FOInputHandler#startCell(TableCell) */ public void startCell(TableCell tc) { - try - { - TableContext tctx=m_context.getTableContext(); - final RtfTableRow row = (RtfTableRow)m_context.getContainer(RtfTableRow.class,true,null); + try { + TableContext tctx = m_context.getTableContext(); + final RtfTableRow row = (RtfTableRow)m_context.getContainer(RtfTableRow.class, + true, null); //while the current column is in row-spanning, act as if //a vertical merged cell would have been specified. - while(tctx.getNumberOfColumns()>tctx.getColumnIndex() && tctx.getColumnRowSpanningNumber().intValue()>0) - { - row.newTableCellMergedVertically((int)tctx.getColumnWidth(),tctx.getColumnRowSpanningAttrs()); + while (tctx.getNumberOfColumns() > tctx.getColumnIndex() + && tctx.getColumnRowSpanningNumber().intValue() > 0) { + row.newTableCellMergedVertically((int)tctx.getColumnWidth(), + tctx.getColumnRowSpanningAttrs()); tctx.selectNextColumn(); } //get the width of the currently started cell - float width=tctx.getColumnWidth(); + float width = tctx.getColumnWidth(); // create an RtfTableCell in the current RtfTableRow - RtfAttributes atts=TableAttributesConverter.convertCellAttributes(tc.properties,null); - RtfTableCell cell=row.newTableCell((int)width, atts); + RtfAttributes atts = TableAttributesConverter.convertCellAttributes(tc.properties, + null); + RtfTableCell cell = row.newTableCell((int)width, atts); //process number-rows-spanned attribute - Property p=null; - if ((p=tc.properties.get("number-rows-spanned")) != null && false) - { + Property p = null; + if ((p = tc.properties.get("number-rows-spanned")) != null && false) { // Start vertical merge cell.setVMerge(RtfTableCell.MERGE_START); // set the number of rows spanned - tctx.setCurrentColumnRowSpanning(new Integer(p.getNumber().intValue()), cell.getRtfAttributes()); - } - else - { - tctx.setCurrentColumnRowSpanning(new Integer(1),null); + tctx.setCurrentColumnRowSpanning(new Integer(p.getNumber().intValue()), + cell.getRtfAttributes()); + } else { + tctx.setCurrentColumnRowSpanning(new Integer(1), null); } m_context.pushContainer(cell); - } - catch(Exception e) - { + } catch (Exception e) { log.error("startCell: " + e.getMessage()); throw new Error(e.getMessage()); } @@ -564,18 +552,17 @@ public class RTFHandler extends FOInputHandler { } } - private void attrBlockFontSize(Block bl, RtfAttributes rtfAttr){ - int fopValue = bl.properties.get("font-size").getLength().getValue()/500; - rtfAttr.set("fs",fopValue); + private void attrBlockFontSize(Block bl, RtfAttributes rtfAttr) { + int fopValue = bl.properties.get("font-size").getLength().getValue() / 500; + rtfAttr.set("fs", fopValue); } - private void attrBlockFontWeight(Block bl, RtfAttributes rtfAttr){ + private void attrBlockFontWeight(Block bl, RtfAttributes rtfAttr) { String fopValue = bl.properties.get("font-weight").getString(); - if(fopValue=="bold" || fopValue=="700"){ - rtfAttr.set("b",1); - } - else{ - rtfAttr.set("b",0); + if (fopValue == "bold" || fopValue == "700") { + rtfAttr.set("b", 1); + } else { + rtfAttr.set("b", 0); } } diff --git a/src/java/org/apache/fop/rtf/renderer/TableAttributesConverter.java b/src/java/org/apache/fop/rtf/renderer/TableAttributesConverter.java index 49f7bb669..00a56bfb6 100644 --- a/src/java/org/apache/fop/rtf/renderer/TableAttributesConverter.java +++ b/src/java/org/apache/fop/rtf/renderer/TableAttributesConverter.java @@ -1,4 +1,5 @@ /* + * $Id$ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ @@ -67,7 +68,6 @@ import org.apache.fop.fo.ColorTypeProperty; import org.apache.fop.fo.NumberProperty; import org.apache.fop.datatypes.ColorType; -import org.xml.sax.Attributes; import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes; import org.apache.fop.rtf.rtflib.rtfdoc.ITableAttributes; import org.apache.fop.rtf.rtflib.rtfdoc.RtfColorTable; @@ -89,7 +89,7 @@ import org.apache.fop.rtf.rtflib.rtfdoc.RtfColorTable; public class TableAttributesConverter { - static Logger log=new ConsoleLogger(); + private static Logger log = new ConsoleLogger(); ////////////////////////////////////////////////// // @@ Construction @@ -120,87 +120,84 @@ public class TableAttributesConverter { Property p; EnumProperty ep; - RtfColorTable colorTable=RtfColorTable.getInstance(); + RtfColorTable colorTable = RtfColorTable.getInstance(); - RtfAttributes attrib=null; + RtfAttributes attrib = null; - if(defProps!=null) - { - attrib=convertCellAttributes(defProps,null); - } - else - { - attrib=new RtfAttributes(); + if (defProps != null) { + attrib = convertCellAttributes(defProps, null); + } else { + attrib = new RtfAttributes(); } - boolean isBorderPresent=false; + boolean isBorderPresent = false; // Cell background color - if ((p=props.getNearestSpecified("background-color"))!=null) - { - ColorType color=p.getColorType(); - if(color!=null) - { - if(color.getAlpha()!=0 - || color.getRed()!=0 - || color.getGreen()!=0 - || color.getBlue()!=0) - { + if ((p = props.getNearestSpecified("background-color")) != null) { + ColorType color = p.getColorType(); + if (color != null) { + if (color.getAlpha() != 0 + || color.getRed() != 0 + || color.getGreen() != 0 + || color.getBlue() != 0) { attrib.set( ITableAttributes.CELL_COLOR_BACKGROUND, RTFHandler.convertFOPColorToRTF(color)); } - } - else - { + } else { log.warn("Named color '" + p.toString() + "' not found. "); } } // Cell borders : - if ((p=props.getExplicit("border-color"))!=null){ - ListProperty listprop=(ListProperty)p; - ColorType color=null; - if(listprop.getList().get(0) instanceof NCnameProperty){ - color=new ColorType(((NCnameProperty)listprop.getList().get(0)).getNCname()); - } - else if(listprop.getList().get(0) instanceof ColorTypeProperty){ - color=((ColorTypeProperty)listprop.getList().get(0)).getColorType(); + if ((p = props.getExplicit("border-color")) != null) { + ListProperty listprop = (ListProperty)p; + ColorType color = null; + if (listprop.getList().get(0) instanceof NCnameProperty) { + color = new ColorType(((NCnameProperty)listprop.getList().get(0)).getNCname()); + } else if (listprop.getList().get(0) instanceof ColorTypeProperty) { + color = ((ColorTypeProperty)listprop.getList().get(0)).getColorType(); } attrib.set( BorderAttributesConverter.BORDER_COLOR, - colorTable.getColorNumber((int)color.getRed(),(int)color.getGreen(),(int)color.getBlue()).intValue()); + colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), + (int)color.getBlue()).intValue()); } - if ((p=props.getExplicit("border-top-color"))!=null){ - ColorType color=p.getColorType(); + if ((p = props.getExplicit("border-top-color")) != null) { + ColorType color = p.getColorType(); attrib.set( BorderAttributesConverter.BORDER_COLOR, - colorTable.getColorNumber((int)color.getRed(),(int)color.getGreen(),(int)color.getBlue()).intValue()); + colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), + (int)color.getBlue()).intValue()); } - if((p=props.getExplicit("border-bottom-color"))!=null){ - ColorType color=p.getColorType(); + if ((p = props.getExplicit("border-bottom-color")) != null) { + ColorType color = p.getColorType(); attrib.set( BorderAttributesConverter.BORDER_COLOR, - colorTable.getColorNumber((int)color.getRed(),(int)color.getGreen(),(int)color.getBlue()).intValue()); + colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), + (int)color.getBlue()).intValue()); } - if((p=props.getExplicit("border-left-color"))!=null){ - ColorType color=p.getColorType(); + if ((p = props.getExplicit("border-left-color")) != null) { + ColorType color = p.getColorType(); attrib.set( BorderAttributesConverter.BORDER_COLOR, - colorTable.getColorNumber((int)color.getRed(),(int)color.getGreen(),(int)color.getBlue()).intValue()); + colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), + (int)color.getBlue()).intValue()); } - if((p=props.getExplicit("border-right-color"))!=null){ - ColorType color=p.getColorType(); + if ((p = props.getExplicit("border-right-color")) != null) { + ColorType color = p.getColorType(); attrib.set( BorderAttributesConverter.BORDER_COLOR, - colorTable.getColorNumber((int)color.getRed(),(int)color.getGreen(),(int)color.getBlue()).intValue()); + colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), + (int)color.getBlue()).intValue()); } // Border styles do not inherit from parent - if((p=props.get("border-style"))!=null){ - log.warn("border-style not implemented. Please use border-style-left, ...-right, ...-top or ...-bottom"); + if ((p = props.get("border-style")) != null) { + log.warn("border-style not implemented. Please use border-style-left, " + + "...-right, ...-top or ...-bottom"); /* attrib.set(ITableAttributes.CELL_BORDER_LEFT, "\\"+convertAttributetoRtf(e.getEnum())); attrib.set(ITableAttributes.CELL_BORDER_RIGHT, "\\"+convertAttributetoRtf(e.getEnum())); @@ -209,46 +206,51 @@ public class TableAttributesConverter { isBorderPresent=true; */ } - ep=(EnumProperty)props.get("border-top-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.CELL_BORDER_TOP, "\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; + ep = (EnumProperty)props.get("border-top-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.CELL_BORDER_TOP, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; } - ep=(EnumProperty)props.get("border-bottom-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.CELL_BORDER_BOTTOM,"\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; + ep = (EnumProperty)props.get("border-bottom-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.CELL_BORDER_BOTTOM, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; } - ep=(EnumProperty)props.get("border-left-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.CELL_BORDER_LEFT, "\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; + ep = (EnumProperty)props.get("border-left-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.CELL_BORDER_LEFT, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; } - ep=(EnumProperty)props.get("border-right-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.CELL_BORDER_RIGHT, "\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; + ep = (EnumProperty)props.get("border-right-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.CELL_BORDER_RIGHT, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; } - if((p=props.get("border-width"))!=null) { - ListProperty listprop=(ListProperty)p; - LengthProperty lengthprop=(LengthProperty)listprop.getList().get(0); + if ((p = props.get("border-width")) != null) { + ListProperty listprop = (ListProperty)p; + LengthProperty lengthprop = (LengthProperty)listprop.getList().get(0); - Float f=new Float(lengthprop.getLength().getValue()/1000f); + Float f = new Float(lengthprop.getLength().getValue() / 1000f); String sValue = f.toString() + "pt"; - attrib.set(BorderAttributesConverter.BORDER_WIDTH, (int)FoUnitsConverter.getInstance().convertToTwips(sValue)); - } - else if(isBorderPresent){ + attrib.set(BorderAttributesConverter.BORDER_WIDTH, + (int)FoUnitsConverter.getInstance().convertToTwips(sValue)); + } else if (isBorderPresent) { //if not defined, set default border width //note 20 twips = 1 point - attrib.set(BorderAttributesConverter.BORDER_WIDTH, (int)FoUnitsConverter.getInstance().convertToTwips("1pt")); + attrib.set(BorderAttributesConverter.BORDER_WIDTH, + (int)FoUnitsConverter.getInstance().convertToTwips("1pt")); } // Column spanning : - NumberProperty n=(NumberProperty)props.get("number-columns-spanned"); - if(n!=null && n.getNumber().intValue()>1) { + NumberProperty n = (NumberProperty)props.get("number-columns-spanned"); + if (n != null && n.getNumber().intValue() > 1) { attrib.set(ITableAttributes.COLUMN_SPAN, n.getNumber().intValue()); } @@ -266,141 +268,172 @@ public class TableAttributesConverter { * * @throws ConverterException On convertion error */ - static RtfAttributes convertRowAttributes(PropertyList props, PropertyList defProps, RtfAttributes rtfatts) + static RtfAttributes convertRowAttributes(PropertyList props, + PropertyList defProps, RtfAttributes rtfatts) throws FOPException { Property p; EnumProperty ep; - RtfColorTable colorTable=RtfColorTable.getInstance(); + RtfColorTable colorTable = RtfColorTable.getInstance(); - RtfAttributes attrib=null; + RtfAttributes attrib = null; - if(defProps!=null) - { - attrib=convertRowAttributes(defProps,null,rtfatts); - } - else - { - if(rtfatts==null) - attrib=new RtfAttributes(); - else - attrib=rtfatts; + if (defProps != null) { + attrib = convertRowAttributes(defProps, null, rtfatts); + } else { + if (rtfatts == null) { + attrib = new RtfAttributes(); + } else { + attrib = rtfatts; + } } String attrValue; - boolean isBorderPresent=false; + boolean isBorderPresent = false; //need to set a default width //check for keep-together row attribute - if ((p=props.get("keep-together.within-page"))!=null){ + if ((p = props.get("keep-together.within-page")) != null) { attrib.set(ITableAttributes.ROW_KEEP_TOGETHER); } - if ((p=props.get("keep-together"))!=null){ + if ((p = props.get("keep-together")) != null) { attrib.set(ITableAttributes.ROW_KEEP_TOGETHER); } //Check for keep-with-next row attribute. - if ((p=props.get("keep-together"))!=null){ + if ((p = props.get("keep-together")) != null) { attrib.set(ITableAttributes.ROW_KEEP_WITH_NEXT); } //Check for keep-with-previous row attribute. - if ((p=props.get("keep-with-previous"))!=null){ + if ((p = props.get("keep-with-previous")) != null) { attrib.set(ITableAttributes.ROW_KEEP_WITH_PREVIOUS); } //Check for height row attribute. - if ((p=props.get("height"))!=null){ - Float f=new Float(p.getLength().getValue()/1000); + if ((p = props.get("height")) != null) { + Float f = new Float(p.getLength().getValue() / 1000); attrValue = f.toString() + "pt"; - attrib.set(ITableAttributes.ROW_HEIGHT, (int)FoUnitsConverter.getInstance().convertToTwips(attrValue)); - } - - /* to write a border to a side of a cell one must write the directional side (ie. left, right) and the inside value - * if one needs to be taken out ie if the cell lies on the edge of a table or not, the offending value will be taken out - * by RtfTableRow. This is because you can't say BORDER_TOP and BORDER_HORIZONTAL if the cell lies at the - * top of the table. Similarly using BORDER_BOTTOM and BORDER_HORIZONTAL will not work if the cell lies at th - * bottom of the table. The same rules apply for left right and vertical. - - * Also, the border type must be written after every control word. Thus it is implemented that the border type is the value - * of the border place. + attrib.set(ITableAttributes.ROW_HEIGHT, + (int)FoUnitsConverter.getInstance().convertToTwips(attrValue)); + } + + /* to write a border to a side of a cell one must write the directional + * side (ie. left, right) and the inside value if one needs to be taken + * out ie if the cell lies on the edge of a table or not, the offending + * value will be taken out by RtfTableRow. This is because you can't + * say BORDER_TOP and BORDER_HORIZONTAL if the cell lies at the top of + * the table. Similarly using BORDER_BOTTOM and BORDER_HORIZONTAL will + * not work if the cell lies at th bottom of the table. The same rules + * apply for left right and vertical. + + * Also, the border type must be written after every control word. Thus + * it is implemented that the border type is the value of the border + * place. */ - if((p=props.get("border-style"))!=null){ - log.warn("border-style not implemented. Please use border-style-left, ...-right, ...-top or ...-bottom"); - -// attrValue = new String(AbstractBuilder.getValue( attrs, "border-style", defAttrs )); -// attrib.set(ITableAttributes.ROW_BORDER_LEFT,"\\"+BorderAttributesConverter.convertAttributetoRtf(attrValue)); -// attrib.set(ITableAttributes.ROW_BORDER_RIGHT,"\\"+BorderAttributesConverter.convertAttributetoRtf(attrValue)); -// attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL,"\\"+BorderAttributesConverter.convertAttributetoRtf(attrValue)); -// attrib.set(ITableAttributes.ROW_BORDER_VERTICAL,"\\"+BorderAttributesConverter.convertAttributetoRtf(attrValue)); -// attrib.set(ITableAttributes.ROW_BORDER_BOTTOM,"\\"+BorderAttributesConverter.convertAttributetoRtf(attrValue)); -// attrib.set(ITableAttributes.ROW_BORDER_TOP,"\\"+BorderAttributesConverter.convertAttributetoRtf(attrValue)); -// isBorderPresent=true; - } - ep=(EnumProperty)props.get("border-top-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.ROW_BORDER_TOP, "\\"+convertAttributetoRtf(ep.getEnum())); - attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL,"\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; - } - ep=(EnumProperty)props.get("border-bottom-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.ROW_BORDER_BOTTOM, "\\"+convertAttributetoRtf(ep.getEnum())); - attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL,"\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; - } - ep=(EnumProperty)props.get("border-left-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.ROW_BORDER_LEFT, "\\"+convertAttributetoRtf(ep.getEnum())); - attrib.set(ITableAttributes.ROW_BORDER_VERTICAL, "\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; - } - ep=(EnumProperty)props.get("border-right-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.ROW_BORDER_RIGHT, "\\"+convertAttributetoRtf(ep.getEnum())); - attrib.set(ITableAttributes.ROW_BORDER_VERTICAL, "\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; - } - ep=(EnumProperty)props.get("border-horizontal-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL, "\\"+convertAttributetoRtf(ep.getEnum())); - attrib.set(ITableAttributes.ROW_BORDER_TOP, "\\"+convertAttributetoRtf(ep.getEnum())); - attrib.set(ITableAttributes.ROW_BORDER_BOTTOM, "\\"+convertAttributetoRtf(ep.getEnum())); - isBorderPresent=true; - } - ep=(EnumProperty)props.get("border-vertical-style"); - if(ep!=null && ep.getEnum()!=Constants.NONE){ - attrib.set(ITableAttributes.ROW_BORDER_VERTICAL, "\\"+convertAttributetoRtf(ep.getEnum())); - attrib.set(ITableAttributes.ROW_BORDER_LEFT, "\\"+convertAttributetoRtf(ep.getEnum())); - attrib.set(ITableAttributes.ROW_BORDER_RIGHT, "\\"+convertAttributetoRtf(ep.getEnum())); + if ((p = props.get("border-style")) != null) { + log.warn("border-style not implemented. Please use border-style-left, " + + "...-right, ...-top or ...-bottom"); +/* + attrValue = new String(AbstractBuilder.getValue( attrs, "border-style", defAttrs )); + attrib.set(ITableAttributes.ROW_BORDER_LEFT,"\\" + + BorderAttributesConverter.convertAttributetoRtf(attrValue)); + attrib.set(ITableAttributes.ROW_BORDER_RIGHT,"\\" + + BorderAttributesConverter.convertAttributetoRtf(attrValue)); + attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL,"\\" + + BorderAttributesConverter.convertAttributetoRtf(attrValue)); + attrib.set(ITableAttributes.ROW_BORDER_VERTICAL,"\\" + + BorderAttributesConverter.convertAttributetoRtf(attrValue)); + attrib.set(ITableAttributes.ROW_BORDER_BOTTOM,"\\" + + BorderAttributesConverter.convertAttributetoRtf(attrValue)); + attrib.set(ITableAttributes.ROW_BORDER_TOP,"\\" + + BorderAttributesConverter.convertAttributetoRtf(attrValue)); isBorderPresent=true; - } - - if((p=props.get("border-width"))!=null){ - ListProperty listprop=(ListProperty)p; - LengthProperty lengthprop=(LengthProperty)listprop.getList().get(0); - - Float f=new Float(lengthprop.getLength().getValue()/1000f); +*/ + } + ep = (EnumProperty)props.get("border-top-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.ROW_BORDER_TOP, "\\" + + convertAttributetoRtf(ep.getEnum())); + attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; + } + ep = (EnumProperty)props.get("border-bottom-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.ROW_BORDER_BOTTOM, "\\" + + convertAttributetoRtf(ep.getEnum())); + attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; + } + ep = (EnumProperty)props.get("border-left-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.ROW_BORDER_LEFT, "\\" + + convertAttributetoRtf(ep.getEnum())); + attrib.set(ITableAttributes.ROW_BORDER_VERTICAL, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; + } + ep = (EnumProperty)props.get("border-right-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.ROW_BORDER_RIGHT, "\\" + + convertAttributetoRtf(ep.getEnum())); + attrib.set(ITableAttributes.ROW_BORDER_VERTICAL, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; + } + ep = (EnumProperty)props.get("border-horizontal-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL, "\\" + + convertAttributetoRtf(ep.getEnum())); + attrib.set(ITableAttributes.ROW_BORDER_TOP, "\\" + + convertAttributetoRtf(ep.getEnum())); + attrib.set(ITableAttributes.ROW_BORDER_BOTTOM, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; + } + ep = (EnumProperty)props.get("border-vertical-style"); + if (ep != null && ep.getEnum() != Constants.NONE) { + attrib.set(ITableAttributes.ROW_BORDER_VERTICAL, "\\" + + convertAttributetoRtf(ep.getEnum())); + attrib.set(ITableAttributes.ROW_BORDER_LEFT, "\\" + + convertAttributetoRtf(ep.getEnum())); + attrib.set(ITableAttributes.ROW_BORDER_RIGHT, "\\" + + convertAttributetoRtf(ep.getEnum())); + isBorderPresent = true; + } + + if ((p = props.get("border-width")) != null) { + ListProperty listprop = (ListProperty)p; + LengthProperty lengthprop = (LengthProperty)listprop.getList().get(0); + + Float f = new Float(lengthprop.getLength().getValue() / 1000f); String sValue = f.toString() + "pt"; - attrib.set(BorderAttributesConverter.BORDER_WIDTH, (int)FoUnitsConverter.getInstance().convertToTwips(sValue)); - } - else if(isBorderPresent){ + attrib.set(BorderAttributesConverter.BORDER_WIDTH, + (int)FoUnitsConverter.getInstance().convertToTwips(sValue)); + } else if (isBorderPresent) { //if not defined, set default border width //note 20 twips = 1 point - attrib.set(BorderAttributesConverter.BORDER_WIDTH, (int)FoUnitsConverter.getInstance().convertToTwips("1pt")); + attrib.set(BorderAttributesConverter.BORDER_WIDTH, + (int)FoUnitsConverter.getInstance().convertToTwips("1pt")); } return attrib; } - + /** + * + * @param iBorderStyle the border style to be converted + * @return String with the converted border style + */ public static String convertAttributetoRtf(int iBorderStyle) { // Added by Normand Masse // "solid" is interpreted like "thin" - if (iBorderStyle==Constants.SOLID) { + if (iBorderStyle == Constants.SOLID) { return BorderAttributesConverter.BORDER_SINGLE_THICKNESS; /* } else if (iBorderStyle==Constants.THIN) { return BorderAttributesConverter.BORDER_SINGLE_THICKNESS; @@ -408,11 +441,11 @@ public class TableAttributesConverter { return BorderAttributesConverter.BORDER_DOUBLE_THICKNESS; } else if (iBorderStyle==Constants. value.equals("shadowed")) { return BorderAttributesConverter.BORDER_SHADOWED;*/ - } else if (iBorderStyle==Constants.DOUBLE) { + } else if (iBorderStyle == Constants.DOUBLE) { return BorderAttributesConverter.BORDER_DOUBLE; - } else if (iBorderStyle==Constants.DOTTED) { + } else if (iBorderStyle == Constants.DOTTED) { return BorderAttributesConverter.BORDER_DOTTED; - } else if (iBorderStyle==Constants.DASHED) { + } else if (iBorderStyle == Constants.DASHED) { return BorderAttributesConverter.BORDER_DASH; /* } else if (iBorderStyle==Constants value.equals("hairline")) { return BorderAttributesConverter.BORDER_HAIRLINE;*/ diff --git a/src/java/org/apache/fop/rtf/renderer/TableContext.java b/src/java/org/apache/fop/rtf/renderer/TableContext.java index 088da98a9..cd281f17b 100644 --- a/src/java/org/apache/fop/rtf/renderer/TableContext.java +++ b/src/java/org/apache/fop/rtf/renderer/TableContext.java @@ -1,4 +1,5 @@ /* + * $Id$ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ @@ -49,7 +50,7 @@ */ package org.apache.fop.rtf.renderer; -import java.util.*; +import java.util.ArrayList; import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.framework.logger.Logger; @@ -69,9 +70,8 @@ import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; * is now integrated into FOP. */ -class TableContext implements ITableColumnsInfo -{ - private final Logger log=new ConsoleLogger(); +class TableContext implements ITableColumnsInfo { + private final Logger log = new ConsoleLogger(); private final BuilderContext m_context; private final ArrayList m_colWidths = new ArrayList(); private int m_colIndex; @@ -92,64 +92,53 @@ class TableContext implements ITableColumnsInfo * For this purpose the attributes of a cell are stored in this array, as soon * as a number-rows-spanned attribute has been found. */ - private final ArrayList m_colRowSpanningAttrs = new ArrayList(); //Added by Peter Herweg on 2002-06-29 + private final ArrayList m_colRowSpanningAttrs = new ArrayList(); - private boolean m_bNextRowBelongsToHeader=false; + private boolean m_bNextRowBelongsToHeader = false; - public void setNextRowBelongsToHeader(boolean bNextRowBelongsToHeader) - { - m_bNextRowBelongsToHeader=bNextRowBelongsToHeader; + public void setNextRowBelongsToHeader(boolean bNextRowBelongsToHeader) { + m_bNextRowBelongsToHeader = bNextRowBelongsToHeader; } - public boolean getNextRowBelongsToHeader() - { - return m_bNextRowBelongsToHeader; - } + public boolean getNextRowBelongsToHeader() { + return m_bNextRowBelongsToHeader; + } - TableContext(BuilderContext ctx) - { + TableContext(BuilderContext ctx) { m_context = ctx; } void setNextColumnWidth(String strWidth) - throws Exception - { - - m_colWidths.add( new Float(FoUnitsConverter.getInstance().convertToTwips(strWidth))); + throws Exception { + m_colWidths.add(new Float(FoUnitsConverter.getInstance().convertToTwips(strWidth))); } //Added by Peter Herweg on 2002-06-29 - RtfAttributes getColumnRowSpanningAttrs() - { + RtfAttributes getColumnRowSpanningAttrs() { return (RtfAttributes)m_colRowSpanningAttrs.get(m_colIndex); } //Added by Peter Herweg on 2002-06-29 - Integer getColumnRowSpanningNumber() - { + Integer getColumnRowSpanningNumber() { return (Integer)m_colRowSpanningNumber.get(m_colIndex); } //Added by Peter Herweg on 2002-06-29 void setCurrentColumnRowSpanning(Integer iRowSpanning, RtfAttributes attrs) - throws Exception - { + throws Exception { - if(m_colIndex<m_colRowSpanningNumber.size()) - { + if (m_colIndex < m_colRowSpanningNumber.size()) { m_colRowSpanningNumber.set(m_colIndex, iRowSpanning); m_colRowSpanningAttrs.set(m_colIndex, attrs); - } - else - { + } else { m_colRowSpanningNumber.add(iRowSpanning); m_colRowSpanningAttrs.add(m_colIndex, attrs); } } //Added by Peter Herweg on 2002-06-29 - public void setNextColumnRowSpanning(Integer iRowSpanning, RtfAttributes attrs) - { + public void setNextColumnRowSpanning(Integer iRowSpanning, + RtfAttributes attrs) { m_colRowSpanningNumber.add(iRowSpanning); m_colRowSpanningAttrs.add(m_colIndex, attrs); } @@ -160,47 +149,50 @@ class TableContext implements ITableColumnsInfo * It decreases all values in m_colRowSpanningNumber by 1. If a value * reaches 0 row-spanning is finished, and the value won't be decreased anymore. */ - public void decreaseRowSpannings() - { - for(int z=0;z<m_colRowSpanningNumber.size();++z) - { - Integer i=(Integer)m_colRowSpanningNumber.get(z); + public void decreaseRowSpannings() { + for (int z = 0; z < m_colRowSpanningNumber.size(); ++z) { + Integer i = (Integer)m_colRowSpanningNumber.get(z); - if(i.intValue()>0) - i=new Integer(i.intValue()-1); + if (i.intValue() > 0) { + i = new Integer(i.intValue() - 1); + } - m_colRowSpanningNumber.set(z,i); + m_colRowSpanningNumber.set(z, i); - if(i.intValue()==0) - m_colRowSpanningAttrs.set(z,null); + if (i.intValue() == 0) { + m_colRowSpanningAttrs.set(z, null); + } } } - /** reset the column iteration index, meant to be called when creating a new row - * The 'public' modifier has been added by Boris Poudérous for 'number-columns-spanned' processing + /** + * Reset the column iteration index, meant to be called when creating a new row + * The 'public' modifier has been added by Boris Poudérous for + * 'number-columns-spanned' processing */ - public void selectFirstColumn() - { + public void selectFirstColumn() { m_colIndex = 0; } - /** increment the column iteration index - * The 'public' modifier has been added by Boris Poudérous for 'number-columns-spanned' processing + /** + * Increment the column iteration index + * The 'public' modifier has been added by Boris Poudérous for + * 'number-columns-spanned' processing */ - public void selectNextColumn() - { + public void selectNextColumn() { m_colIndex++; } - /** get current column width according to column iteration index - * @return INVALID_COLUMN_WIDTH if we cannot find the value - * The 'public' modifier has been added by Boris Poudérous for 'number-columns-spanned' processing + /** + * Get current column width according to column iteration index + * @return INVALID_COLUMN_WIDTH if we cannot find the value + * The 'public' modifier has been added by Boris Poudérous for + * 'number-columns-spanned' processing */ - public float getColumnWidth() - { + public float getColumnWidth() { try { return ((Float)m_colWidths.get(m_colIndex)).floatValue(); - } catch (IndexOutOfBoundsException ex) { + } catch (IndexOutOfBoundsException ex) { // this code contributed by Trembicki-Guy, Ed <GuyE@DNB.com> log.warn("fo:table-column width not defined, using " + INVALID_COLUM_WIDTH); return INVALID_COLUM_WIDTH; @@ -208,15 +200,13 @@ class TableContext implements ITableColumnsInfo } /** Added by Boris Poudérous on 07/22/2002 */ - public int getColumnIndex() - { + public int getColumnIndex() { return m_colIndex; } /** - end - */ /** Added by Boris Poudérous on 07/22/2002 */ - public int getNumberOfColumns() - { + public int getNumberOfColumns() { return m_colWidths.size(); } /** - end - */ |