aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Vladimirov <sergey@apache.org>2011-09-22 20:57:10 +0000
committerSergey Vladimirov <sergey@apache.org>2011-09-22 20:57:10 +0000
commita772eb9e2ceef0579a3e16b09df192729f432e54 (patch)
tree5866cd2d7d57bd04bab0dac354a1d5346fbaa689
parent07e31b187929ff644e20f818ec50f2032f6e1c66 (diff)
downloadpoi-a772eb9e2ceef0579a3e16b09df192729f432e54.tar.gz
poi-a772eb9e2ceef0579a3e16b09df192729f432e54.zip
remove incorrect method to lookup "upper" table cell. In fact, we don't need it at all.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1174386 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java61
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java14
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java8
4 files changed, 47 insertions, 44 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
index cf5ea422f4..69e8b8428c 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
@@ -183,7 +183,8 @@ public abstract class AbstractWordConverter
return colSpan;
}
- protected int getNumberRowsSpanned( Table table, int currentRowIndex,
+ protected int getNumberRowsSpanned( Table table,
+ final int[] tableCellEdges, int currentRowIndex,
int currentColumnIndex, TableCell tableCell )
{
if ( !tableCell.isFirstVerticallyMerged() )
@@ -197,6 +198,35 @@ public abstract class AbstractWordConverter
TableRow nextRow = table.getRow( r1 );
if ( currentColumnIndex >= nextRow.numCells() )
break;
+
+ // we need to skip row if he don't have cells at all
+ boolean hasCells = false;
+ int currentEdgeIndex = 0;
+ for ( int c = 0; c < nextRow.numCells(); c++ )
+ {
+ TableCell nextTableCell = nextRow.getCell( c );
+ if ( !nextTableCell.isVerticallyMerged()
+ || nextTableCell.isFirstVerticallyMerged() )
+ {
+ int colSpan = getNumberColumnsSpanned( tableCellEdges,
+ currentEdgeIndex, nextTableCell );
+ currentEdgeIndex += colSpan;
+
+ if ( colSpan != 0 )
+ {
+ hasCells = true;
+ break;
+ }
+ }
+ else
+ {
+ currentEdgeIndex += getNumberColumnsSpanned(
+ tableCellEdges, currentEdgeIndex, nextTableCell );
+ }
+ }
+ if ( !hasCells )
+ continue;
+
TableCell nextCell = nextRow.getCell( currentColumnIndex );
if ( !nextCell.isVerticallyMerged()
|| nextCell.isFirstVerticallyMerged() )
@@ -211,35 +241,6 @@ public abstract class AbstractWordConverter
return picturesManager;
}
- protected int getTableCellEdgesIndexSkipCount( Table table, int r,
- int[] tableCellEdges, int currentEdgeIndex, int c,
- TableCell tableCell )
- {
- TableCell upperCell = null;
- for ( int r1 = r - 1; r1 >= 0; r1-- )
- {
- final TableRow row = table.getRow( r1 );
- if ( row == null || c >= row.numCells() )
- continue;
-
- final TableCell prevCell = row.getCell( c );
- if ( prevCell != null && prevCell.isFirstVerticallyMerged() )
- {
- upperCell = prevCell;
- break;
- }
- }
- if ( upperCell == null )
- {
- logger.log( POILogger.WARN, "First vertically merged cell for ",
- tableCell, " not found" );
- return 0;
- }
-
- return getNumberColumnsSpanned( tableCellEdges, currentEdgeIndex,
- tableCell );
- }
-
protected abstract void outputCharacters( Element block,
CharacterRun characterRun, String text );
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java
index 90cf8aff2e..cde7076aac 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java
@@ -557,8 +557,8 @@ public class WordToFoConverter extends AbstractWordConverter
if ( tableCell.isVerticallyMerged()
&& !tableCell.isFirstVerticallyMerged() )
{
- currentEdgeIndex += getTableCellEdgesIndexSkipCount( table,
- r, tableCellEdges, currentEdgeIndex, c, tableCell );
+ currentEdgeIndex += getNumberColumnsSpanned(
+ tableCellEdges, currentEdgeIndex, tableCell );
continue;
}
@@ -578,8 +578,8 @@ public class WordToFoConverter extends AbstractWordConverter
tableCellElement.setAttribute( "number-columns-spanned",
String.valueOf( colSpan ) );
- final int rowSpan = getNumberRowsSpanned( table, r, c,
- tableCell );
+ final int rowSpan = getNumberRowsSpanned( table,
+ tableCellEdges, r, c, tableCell );
if ( rowSpan > 1 )
tableCellElement.setAttribute( "number-rows-spanned",
String.valueOf( rowSpan ) );
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java
index da2a881a1c..e901de8216 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java
@@ -76,12 +76,14 @@ public class WordToFoUtils extends AbstractWordUtils
{
inline.setAttribute( "color", getColor24( characterRun.getIco24() ) );
}
- final int opacity = (int) ( characterRun.getIco24() & 0xFF000000l ) >>> 24;
- if ( opacity != 0 && opacity != 0xFF )
- {
- inline.setAttribute( "opacity",
- getOpacity( characterRun.getIco24() ) );
- }
+ /* XLS FO 1.1 doesn't support opacity -- sergey */
+ // final int opacity = (int) ( characterRun.getIco24() & 0xFF000000l )
+ // >>> 24;
+ // if ( opacity != 0 && opacity != 0xFF )
+ // {
+ // inline.setAttribute( "opacity",
+ // getOpacity( characterRun.getIco24() ) );
+ // }
if ( characterRun.isCapitalized() )
{
inline.setAttribute( "text-transform", "uppercase" );
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
index 50ec5c2081..b9450f1685 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
@@ -662,8 +662,8 @@ public class WordToHtmlConverter extends AbstractWordConverter
if ( tableCell.isVerticallyMerged()
&& !tableCell.isFirstVerticallyMerged() )
{
- currentEdgeIndex += getTableCellEdgesIndexSkipCount( table,
- r, tableCellEdges, currentEdgeIndex, c, tableCell );
+ currentEdgeIndex += getNumberColumnsSpanned(
+ tableCellEdges, currentEdgeIndex, tableCell );
continue;
}
@@ -693,8 +693,8 @@ public class WordToHtmlConverter extends AbstractWordConverter
tableCellElement.setAttribute( "colspan",
String.valueOf( colSpan ) );
- final int rowSpan = getNumberRowsSpanned( table, r, c,
- tableCell );
+ final int rowSpan = getNumberRowsSpanned( table,
+ tableCellEdges, r, c, tableCell );
if ( rowSpan > 1 )
tableCellElement.setAttribute( "rowspan",
String.valueOf( rowSpan ) );