CVS: jfor/src/org/jfor/jfor/converter TableAttributesConverter.java,1.7,1.8 TableBuilder.java,1.4,1.5 TableContext.java,1.4,1.5
Bertrand Delacretaz <[email protected]> Mon, 12 Aug 2002 02:40:04 -0700
| Newsgroups | gmane.text.xml.jfor.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jfor/jfor/src/org/jfor/jfor/converter
In directory usw-pr-cvs1:/tmp/cvs-serv13488/src/org/jfor/jfor/converter
Modified Files:
TableAttributesConverter.java TableBuilder.java
TableContext.java
Log Message:
V0.7.1dev-e, contributions from Boris Poudérous for number-columns-spanned
and vertical merging of tables cells.
Index: TableAttributesConverter.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/TableAttributesConverter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** TableAttributesConverter.java 17 Jul 2002 18:12:28 -0000 1.7
--- TableAttributesConverter.java 12 Aug 2002 09:40:02 -0000 1.8
***************
*** 64,67 ****
--- 64,71 ----
// $Id$
// $Log$
+ // Revision 1.8 2002/08/12 09:40:02 bdelacretaz
+ // V0.7.1dev-e, contributions from Boris Poudérous for number-columns-spanned
+ // and vertical merging of tables cells.
+ //
// Revision 1.7 2002/07/17 18:12:28 rmarra
// Contributions for background-color processing and
***************
*** 89,93 ****
// @@ Construction
//////////////////////////////////////////////////
!
/**
* Constructor.
--- 93,97 ----
// @@ Construction
//////////////////////////////////////////////////
!
/**
* Constructor.
***************
*** 95,104 ****
private TableAttributesConverter() {
}
!
!
//////////////////////////////////////////////////
// @@ Static converter methods
//////////////////////////////////////////////////
!
/**
* Converts cell attributes to rtf attributes.
--- 99,108 ----
private TableAttributesConverter() {
}
!
!
//////////////////////////////////////////////////
// @@ Static converter methods
//////////////////////////////////////////////////
!
/**
* Converts cell attributes to rtf attributes.
***************
*** 118,122 ****
//need to set a default width
! // Cell background color
/**
* Added by Boris POUDEROUS on 2002/06/25
--- 122,126 ----
//need to set a default width
! // Cell background color
/**
* Added by Boris POUDEROUS on 2002/06/25
***************
*** 127,131 ****
attrib.set(ITableAttributes.CELL_COLOR_BACKGROUND, FoColorConverter.getInstance().getRtfColorNumber(attrValue, null).intValue());
}
!
// Cell borders :
/**
--- 131,135 ----
attrib.set(ITableAttributes.CELL_COLOR_BACKGROUND, FoColorConverter.getInstance().getRtfColorNumber(attrValue, null).intValue());
}
!
// Cell borders :
/**
***************
*** 157,161 ****
isBorderPresent=true;
}
!
if(AbstractBuilder.attributeIsSet(attrs,"border-style")){
attrValue = new String(attrs.getValue("border-style"));
--- 161,165 ----
isBorderPresent=true;
}
!
if(AbstractBuilder.attributeIsSet(attrs,"border-style")){
attrValue = new String(attrs.getValue("border-style"));
***************
*** 190,194 ****
isBorderPresent=true;
}
!
if(AbstractBuilder.attributeIsSet(attrs,"border-width")) {
attrValue = new String(attrs.getValue("border-width"));
--- 194,198 ----
isBorderPresent=true;
}
!
if(AbstractBuilder.attributeIsSet(attrs,"border-width")) {
attrValue = new String(attrs.getValue("border-width"));
***************
*** 201,209 ****
(int)FoUnitsConverter.getInstance().convertToTwips("1pt"));
}
!
return convertAttributes(attrs, attrib,true);
}
!
!
/**
* Converts table and row attributes to rtf attributes.
--- 205,233 ----
(int)FoUnitsConverter.getInstance().convertToTwips("1pt"));
}
!
!
! // Column spanning :
! /**
! * Added by Boris POUDEROUS on 2002/06/27
! */
! if(AbstractBuilder.attributeIsSet(attrs,"number-columns-spanned")) {
! attrValue = new String(attrs.getValue("number-columns-spanned"));
! // Check whether if the number of columns is correct :
! boolean set = true;
! for (int i = 0; i < attrValue.length(); i++)
! {
! if (!Character.isDigit(attrValue.charAt(i)))
! set = false;
! }
! if (set)
! {
! attrib.set(ITableAttributes.COLUMN_SPAN, Integer.parseInt(attrValue));
! }
! }
!
return convertAttributes(attrs, attrib,true);
}
!
!
/**
* Converts table and row attributes to rtf attributes.
***************
*** 222,249 ****
boolean isBorderPresent=false;
//need to set a default width
!
//check for keep-together row attribute
if(AbstractBuilder.attributeIsSet(attrs,"keep-together.within-page")) {
attrib.set(ITableAttributes.ROW_KEEP_TOGETHER);
}
!
!
if(AbstractBuilder.attributeIsSet(attrs,"keep-together")) {
attrib.set(ITableAttributes.ROW_KEEP_TOGETHER);
}
!
!
//Check for keep-with-next row attribute.
if (AbstractBuilder.attributeIsSet(attrs,"keep-with-next")) {
! attrib.set(ITableAttributes.ROW_KEEP_WITH_NEXT);
}
!
//Check for keep-with-previous row attribute.
if (AbstractBuilder.attributeIsSet(attrs,"keep-with-previous")) {
! attrib.set(ITableAttributes.ROW_KEEP_WITH_PREVIOUS);
}
!
!
/* 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
--- 246,273 ----
boolean isBorderPresent=false;
//need to set a default width
!
//check for keep-together row attribute
if(AbstractBuilder.attributeIsSet(attrs,"keep-together.within-page")) {
attrib.set(ITableAttributes.ROW_KEEP_TOGETHER);
}
!
!
if(AbstractBuilder.attributeIsSet(attrs,"keep-together")) {
attrib.set(ITableAttributes.ROW_KEEP_TOGETHER);
}
!
!
//Check for keep-with-next row attribute.
if (AbstractBuilder.attributeIsSet(attrs,"keep-with-next")) {
! attrib.set(ITableAttributes.ROW_KEEP_WITH_NEXT);
}
!
//Check for keep-with-previous row attribute.
if (AbstractBuilder.attributeIsSet(attrs,"keep-with-previous")) {
! attrib.set(ITableAttributes.ROW_KEEP_WITH_PREVIOUS);
}
!
!
/* 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
***************
*** 317,322 ****
isBorderPresent=true;
}
!
!
if(AbstractBuilder.attributeIsSet(attrs,"border-width")) {
attrValue = new String(attrs.getValue("border-width"));
--- 341,346 ----
isBorderPresent=true;
}
!
!
if(AbstractBuilder.attributeIsSet(attrs,"border-width")) {
attrValue = new String(attrs.getValue("border-width"));
***************
*** 329,341 ****
(int)FoUnitsConverter.getInstance().convertToTwips("1pt"));
}
!
return convertAttributes(attrs, attrib,false);
}
!
!
//////////////////////////////////////////////////
// @@ Private static converter methods
//////////////////////////////////////////////////
!
/**
* Converts xsl:fo attributes to RTF table/row/cell attributes.
--- 353,365 ----
(int)FoUnitsConverter.getInstance().convertToTwips("1pt"));
}
!
return convertAttributes(attrs, attrib,false);
}
!
!
//////////////////////////////////////////////////
// @@ Private static converter methods
//////////////////////////////////////////////////
!
/**
* Converts xsl:fo attributes to RTF table/row/cell attributes.
***************
*** 352,374 ****
RtfAttributes defaultAttributes, boolean cell) throws ConverterException {
RtfAttributes result = null;
!
// first copy default attributes if any
result = defaultAttributes == null ? null : (RtfAttributes) defaultAttributes.clone();
!
if (attrs == null) {
return result;
!
// row-padding (all)
}
!
final String padA = AbstractBuilder.getAttribute(attrs, null, "padding", false);
!
if (padA != null) {
if (result == null) {
result = new RtfAttributes();
}
!
int twips = (int) FoUnitsConverter.getInstance().convertToTwips(padA);
!
addTopPadding(result, twips, cell);
addLeftPadding(result, twips, cell);
--- 376,398 ----
RtfAttributes defaultAttributes, boolean cell) throws ConverterException {
RtfAttributes result = null;
!
// first copy default attributes if any
result = defaultAttributes == null ? null : (RtfAttributes) defaultAttributes.clone();
!
if (attrs == null) {
return result;
!
// row-padding (all)
}
!
final String padA = AbstractBuilder.getAttribute(attrs, null, "padding", false);
!
if (padA != null) {
if (result == null) {
result = new RtfAttributes();
}
!
int twips = (int) FoUnitsConverter.getInstance().convertToTwips(padA);
!
addTopPadding(result, twips, cell);
addLeftPadding(result, twips, cell);
***************
*** 377,440 ****
}
else {
!
// row-padding-top
final String padT = AbstractBuilder.getAttribute(attrs, null, "padding-top", false);
!
if (padT != null) {
if (result == null) {
result = new RtfAttributes();
}
!
addTopPadding(result, (int) FoUnitsConverter.getInstance().convertToTwips(padT),
cell);
}
!
// row-padding-left
final String padL = AbstractBuilder.getAttribute(attrs, null, "padding-left", false);
!
if (padL != null) {
if (result == null) {
result = new RtfAttributes();
}
!
addLeftPadding(result,
(int) FoUnitsConverter.getInstance().convertToTwips(padL), cell);
}
!
// row-padding-bottom
final String padB = AbstractBuilder.getAttribute(attrs, null, "padding-bottom", false);
!
if (padB != null) {
if (result == null) {
result = new RtfAttributes();
}
!
addBottomPadding(result,
(int) FoUnitsConverter.getInstance().convertToTwips(padB),
cell);
}
!
// row-padding-right
final String padR = AbstractBuilder.getAttribute(attrs, null, "padding-right", false);
!
if (padR != null) {
if (result == null) {
result = new RtfAttributes();
}
!
addRightPadding(result,
(int) FoUnitsConverter.getInstance().convertToTwips(padR), cell);
}
}
!
!
return result;
}
!
!
//////////////////////////////////////////////////
// @@ Helpers
//////////////////////////////////////////////////
!
/**
* Adds the top padding attribute to the rtf attributes.
--- 401,464 ----
}
else {
!
// row-padding-top
final String padT = AbstractBuilder.getAttribute(attrs, null, "padding-top", false);
!
if (padT != null) {
if (result == null) {
result = new RtfAttributes();
}
!
addTopPadding(result, (int) FoUnitsConverter.getInstance().convertToTwips(padT),
cell);
}
!
// row-padding-left
final String padL = AbstractBuilder.getAttribute(attrs, null, "padding-left", false);
!
if (padL != null) {
if (result == null) {
result = new RtfAttributes();
}
!
addLeftPadding(result,
(int) FoUnitsConverter.getInstance().convertToTwips(padL), cell);
}
!
// row-padding-bottom
final String padB = AbstractBuilder.getAttribute(attrs, null, "padding-bottom", false);
!
if (padB != null) {
if (result == null) {
result = new RtfAttributes();
}
!
addBottomPadding(result,
(int) FoUnitsConverter.getInstance().convertToTwips(padB),
cell);
}
!
// row-padding-right
final String padR = AbstractBuilder.getAttribute(attrs, null, "padding-right", false);
!
if (padR != null) {
if (result == null) {
result = new RtfAttributes();
}
!
addRightPadding(result,
(int) FoUnitsConverter.getInstance().convertToTwips(padR), cell);
}
}
!
!
return result;
}
!
!
//////////////////////////////////////////////////
// @@ Helpers
//////////////////////////////////////////////////
!
/**
* Adds the top padding attribute to the rtf attributes.
***************
*** 454,459 ****
}
}
!
!
/**
* Adds the left padding attribute to the rtf attributes.
--- 478,483 ----
}
}
!
!
/**
* Adds the left padding attribute to the rtf attributes.
***************
*** 473,478 ****
}
}
!
!
/**
* Adds the bottom padding attribute to the rtf attributes.
--- 497,502 ----
}
}
!
!
/**
* Adds the bottom padding attribute to the rtf attributes.
***************
*** 492,497 ****
}
}
!
!
/**
* Adds the right padding attribute to the rtf attributes.
--- 516,521 ----
}
}
!
!
/**
* Adds the right padding attribute to the rtf attributes.
Index: TableBuilder.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/TableBuilder.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TableBuilder.java 12 Jul 2002 08:08:31 -0000 1.4
--- TableBuilder.java 12 Aug 2002 09:40:02 -0000 1.5
***************
*** 62,65 ****
--- 62,69 ----
// $Id$
// $Log$
+ // Revision 1.5 2002/08/12 09:40:02 bdelacretaz
+ // V0.7.1dev-e, contributions from Boris Poudérous for number-columns-spanned
+ // and vertical merging of tables cells.
+ //
// Revision 1.4 2002/07/12 08:08:31 bdelacretaz
// License changed to jfor Apache-style license
***************
*** 88,92 ****
super(ctx);
}
!
/** called by Converter at the start of an element */
public void start(String rawName, Attributes atts)
--- 92,96 ----
super(ctx);
}
!
/** called by Converter at the start of an element */
public void start(String rawName, Attributes atts)
***************
*** 95,102 ****
// create an RtfTable in the current table container
final IRtfTableContainer tc = (IRtfTableContainer)m_context.getContainer(IRtfTableContainer.class,true,this);
! m_context.pushContainer(tc.newTable(TableAttributesConverter.convertRowAttributes (atts, null)));
! m_context.pushTableContext(new TableContext(m_context));
}
!
/** called by Converter at the end of an element */
public void end()
--- 99,109 ----
// create an RtfTable in the current table container
final IRtfTableContainer tc = (IRtfTableContainer)m_context.getContainer(IRtfTableContainer.class,true,this);
! /** Added By Boris POUDEROUS on 07/22/2002 */
! TableContext tableContext = new TableContext(m_context);
! m_context.pushContainer(tc.newTable(TableAttributesConverter.convertRowAttributes (atts, null), tableContext));
! m_context.pushTableContext(tableContext);
! /** - end - */
}
!
/** called by Converter at the end of an element */
public void end()
***************
*** 106,110 ****
m_context.popContainer();
}
!
/** return a TableBuilder for fo:table elements */
public IBuilder getBuilder(BuilderContext ctx,String rawName, Attributes atts)
--- 113,117 ----
m_context.popContainer();
}
!
/** return a TableBuilder for fo:table elements */
public IBuilder getBuilder(BuilderContext ctx,String rawName, Attributes atts)
Index: TableContext.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/TableContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TableContext.java 12 Jul 2002 08:08:31 -0000 1.4
--- TableContext.java 12 Aug 2002 09:40:02 -0000 1.5
***************
*** 2,5 ****
--- 2,6 ----
import java.util.*;
+ import org.jfor.jfor.interfaces.ITableColumnsInfo;
/*-----------------------------------------------------------------------------
***************
*** 60,63 ****
--- 61,68 ----
// $Id$
// $Log$
+ // Revision 1.5 2002/08/12 09:40:02 bdelacretaz
+ // V0.7.1dev-e, contributions from Boris Poudérous for number-columns-spanned
+ // and vertical merging of tables cells.
+ //
// Revision 1.4 2002/07/12 08:08:31 bdelacretaz
// License changed to jfor Apache-style license
***************
*** 77,92 ****
//------------------------------------------------------------------------------
! class TableContext
{
private final BuilderContext m_context;
private final ArrayList m_colWidths = new ArrayList();
private int m_colIndex;
! public static final float INVALID_COLUM_WIDTH = 200f;
!
TableContext(BuilderContext ctx)
{
m_context = ctx;
}
!
void setNextColumnWidth(String strWidth)
throws ValueConversionException
--- 82,96 ----
//------------------------------------------------------------------------------
! class TableContext implements ITableColumnsInfo
{
private final BuilderContext m_context;
private final ArrayList m_colWidths = new ArrayList();
private int m_colIndex;
!
TableContext(BuilderContext ctx)
{
m_context = ctx;
}
!
void setNextColumnWidth(String strWidth)
throws ValueConversionException
***************
*** 94,114 ****
m_colWidths.add(new Float(FoUnitsConverter.getInstance().convertToTwips(strWidth)));
}
!
! /** reset the column iteration index, meant to be called when creating a new row */
! void selectFirstColumn()
{
m_colIndex = 0;
}
!
! /** increment the column iteration index */
! void selectNextColumn()
{
m_colIndex++;
}
!
/** get current column width according to column iteration index
* @return INVALID_COLUMN_WIDTH if we cannot find the value
*/
! float getColumnWidth()
{
try {
--- 98,123 ----
m_colWidths.add(new Float(FoUnitsConverter.getInstance().convertToTwips(strWidth)));
}
!
! /** 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()
{
m_colIndex = 0;
}
!
! /** increment the column iteration index
! * The 'public' modifier has been added by Boris Poudérous for 'number-columns-spanned' processing
! */
! 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
*/
! public float getColumnWidth()
{
try {
***************
*** 120,122 ****
--- 129,145 ----
}
}
+
+ /** Added by Boris Poudérous on 07/22/2002 */
+ public int getColumnIndex()
+ {
+ return m_colIndex;
+ }
+ /** - end - */
+
+ /** Added by Boris Poudérous on 07/22/2002 */
+ public int getNumberOfColumns()
+ {
+ return m_colWidths.size();
+ }
+ /** - end - */
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf