CVS: jfor/src/org/jfor/jfor/converter TableCellBuilder.java,1.5,1.6 TableContext.java,1.5,1.6 TableColumnBuilder.java,1.3,1.4 TableRowBuilder.java,1.5,1.6

Peter Herweg <[email protected]> Sun, 29 Jun 2003 15:31:04 -0700
Newsgroups gmane.text.xml.jfor.cvs
Message-ID <[email protected]>
Update of /cvsroot/jfor/jfor/src/org/jfor/jfor/converter
In directory sc8-pr-cvs1:/tmp/cvs-serv12936

Modified Files:
	TableCellBuilder.java TableContext.java 
	TableColumnBuilder.java TableRowBuilder.java 
Log Message:
support for number-rows-spanned added

Index: TableCellBuilder.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/TableCellBuilder.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TableCellBuilder.java	18 Feb 2003 16:10:49 -0000	1.5
--- TableCellBuilder.java	29 Jun 2003 22:31:02 -0000	1.6
***************
*** 62,67 ****
  // $Id$
  // $Log$
  // Revision 1.5  2003/02/18 16:10:49  rmarra
! // Contributions Normand Massé
  // inheritance and other fixes
  //
--- 62,70 ----
  // $Id$
  // $Log$
+ // Revision 1.6  2003/06/29 22:31:02  pherweg
+ // support for number-rows-spanned added
+ //
  // Revision 1.5  2003/02/18 16:10:49  rmarra
! // Contributions Normand Massé
  // inheritance and other fixes
  //
***************
*** 90,107 ****
      }
  
!     /** called by Converter at the start of an element */
      public void start(String rawName, Attributes atts)
      throws IOException
      {
!         // get width of this column
!         final float width = m_context.getTableContext().getColumnWidth();
! 
!         // create an RtfTableCell in the current RtfTableRow
          final RtfTableRow row = (RtfTableRow)m_context.getContainer(RtfTableRow.class,true,this);
          // Added by Normand Masse
          // Try to use the parents attributes
          RtfAttributes rowAttribs = row.getRtfAttributes();
          RtfAttributes rowCellAttribs = TableAttributesConverter.convertCellAttributes (atts, rowAttribs);
!         m_context.pushContainer(row.newTableCell((int)width, rowCellAttribs));
      }
  
--- 93,140 ----
      }
  
!     /** called by Converter at the start of an element 
!      *  Modified by Peter Herweg on 2003-06-29 in order to support "number-rows-spanned"
!      **/
      public void start(String rawName, Attributes atts)
      throws IOException
      {
!         TableContext tctx=m_context.getTableContext();
          final RtfTableRow row = (RtfTableRow)m_context.getContainer(RtfTableRow.class,true,this);
+         
+                 
+         //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());
+             tctx.selectNextColumn();
+         }
+         
+         //get the width of the currently started cell
+         float width=tctx.getColumnWidth();
+         
          // Added by Normand Masse
          // Try to use the parents attributes
          RtfAttributes rowAttribs = row.getRtfAttributes();
          RtfAttributes rowCellAttribs = TableAttributesConverter.convertCellAttributes (atts, rowAttribs);
! 
!         // create an RtfTableCell in the current RtfTableRow
!         RtfTableCell cell=row.newTableCell((int)width, rowCellAttribs);        
!         
!         // Added by Peter Herweg on 06/28/2003 in order to process number-rows-spanned attribute
!         if (atts.getValue("number-rows-spanned") != null)
!         {
!             // Start horizontal merge
!             cell.setVMerge(RtfTableCell.MERGE_START);
!             
!             // set the number of rows spanned
!             tctx.setCurrentColumnRowSpanning(new Integer(atts.getValue("number-rows-spanned")),cell.getRtfAttributes());
!         }
!         else
!         {
!             tctx.setCurrentColumnRowSpanning(new Integer(1),null);
!         }
!         
!         m_context.pushContainer(cell);
      }
  

Index: TableContext.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/TableContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TableContext.java	12 Aug 2002 09:40:02 -0000	1.5
--- TableContext.java	29 Jun 2003 22:31:02 -0000	1.6
***************
*** 2,5 ****
--- 2,7 ----
  
  import java.util.*;
+ import org.jfor.jfor.rtflib.rtfdoc.RtfAttributes;
+ import org.xml.sax.Attributes;
  import org.jfor.jfor.interfaces.ITableColumnsInfo;
  
***************
*** 61,64 ****
--- 63,69 ----
  // $Id$
  // $Log$
+ // Revision 1.6  2003/06/29 22:31:02  pherweg
+ // support for number-rows-spanned added
+ //
  // Revision 1.5  2002/08/12 09:40:02  bdelacretaz
  // V0.7.1dev-e, contributions from Boris Poudérous for number-columns-spanned
***************
*** 87,91 ****
      private final ArrayList m_colWidths = new ArrayList();
      private int m_colIndex;
! 
      TableContext(BuilderContext ctx)
      {
--- 92,114 ----
      private final ArrayList m_colWidths = new ArrayList();
      private int m_colIndex;
!     
!     /**
!      * Added by Peter Herweg on 2002-06-29
!      * This ArrayList contains one element for each column in the table.
!      * value == 0 means there is no row-spanning
!      * value >  0 means there is row-spanning
!      * Each value in the list is decreased by 1 after each finished table-row
!      */
!     private final ArrayList m_colRowSpanningNumber = new ArrayList(); 
!     
!     /**
!      * Added by Peter Herweg on 2002-06-29
!      * If there has a vertical merged cell to be created, its attributes are 
!      * inherited from the corresponding MERGE_START-cell.
!      * 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
!     
      TableContext(BuilderContext ctx)
      {
***************
*** 98,101 ****
--- 121,182 ----
          m_colWidths.add(new Float(FoUnitsConverter.getInstance().convertToTwips(strWidth)));
      }
+     
+     //Added by Peter Herweg on 2002-06-29
+     RtfAttributes getColumnRowSpanningAttrs()
+     {
+         return (RtfAttributes)m_colRowSpanningAttrs.get(m_colIndex);
+     }
+     
+     //Added by Peter Herweg on 2002-06-29
+     Integer getColumnRowSpanningNumber()
+     {
+         return (Integer)m_colRowSpanningNumber.get(m_colIndex);
+     }
+ 
+     //Added by Peter Herweg on 2002-06-29
+     void setCurrentColumnRowSpanning(Integer iRowSpanning,  RtfAttributes attrs)
+     throws ValueConversionException
+     {
+         
+         if(m_colIndex<m_colRowSpanningNumber.size())
+         {
+             m_colRowSpanningNumber.set(m_colIndex, iRowSpanning);
+             m_colRowSpanningAttrs.set(m_colIndex, attrs);
+         }
+         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)
+     {
+         m_colRowSpanningNumber.add(iRowSpanning);
+         m_colRowSpanningAttrs.add(m_colIndex, attrs);
+     }
+     
+     /**
+      * Added by Peter Herweg on 2002-06-29
+      * This function is called after each finished table-row.
+      * 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);
+             
+             if(i.intValue()>0)
+                 i=new Integer(i.intValue()-1);
+                 
+             m_colRowSpanningNumber.set(z,i);
+             
+             if(i.intValue()==0)
+                 m_colRowSpanningAttrs.set(z,null);
+         }
+     }
  
      /** reset the column iteration index, meant to be called when creating a new row
***************
*** 144,145 ****
--- 225,227 ----
       /** - end - */
  }
+ 

Index: TableColumnBuilder.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/TableColumnBuilder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TableColumnBuilder.java	12 Jul 2002 08:08:31 -0000	1.3
--- TableColumnBuilder.java	29 Jun 2003 22:31:02 -0000	1.4
***************
*** 61,64 ****
--- 61,67 ----
  // $Id$
  // $Log$
+ // Revision 1.4  2003/06/29 22:31:02  pherweg
+ // support for number-rows-spanned added
+ //
  // Revision 1.3  2002/07/12 08:08:31  bdelacretaz
  // License changed to jfor Apache-style license
***************
*** 91,94 ****
--- 94,98 ----
          final String width = getAttribute(attrs,rawName,CW,true);
          m_context.getTableContext().setNextColumnWidth(width);
+         m_context.getTableContext().setNextColumnRowSpanning(new Integer(0),null);
      }
      

Index: TableRowBuilder.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/TableRowBuilder.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TableRowBuilder.java	18 Feb 2003 16:10:51 -0000	1.5
--- TableRowBuilder.java	29 Jun 2003 22:31:02 -0000	1.6
***************
*** 62,67 ****
  // $Id$
  // $Log$
  // Revision 1.5  2003/02/18 16:10:51  rmarra
! // Contributions Normand Massé
  // inheritance and other fixes
  //
--- 62,70 ----
  // $Id$
  // $Log$
+ // Revision 1.6  2003/06/29 22:31:02  pherweg
+ // support for number-rows-spanned added
+ //
  // Revision 1.5  2003/02/18 16:10:51  rmarra
! // Contributions Normand Massé
  // inheritance and other fixes
  //
***************
*** 111,114 ****
--- 114,118 ----
      {
          m_context.popContainer();
+         m_context.getTableContext().decreaseRowSpannings();
      }
  



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01