You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by se...@apache.org on 2011/07/05 04:17:55 UTC
svn commit: r1142877 - in /poi/trunk/src/scratchpad:
src/org/apache/poi/hwpf/usermodel/Range.java
testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
Author: sergey
Date: Tue Jul 5 02:17:54 2011
New Revision: 1142877
URL: http://svn.apache.org/viewvc?rev=1142877&view=rev
Log:
fix inner tables handling by Range.getTable() method
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java?rev=1142877&r1=1142876&r2=1142877&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java Tue Jul 5 02:17:54 2011
@@ -17,11 +17,12 @@
package org.apache.poi.hwpf.usermodel;
-import org.apache.poi.util.LittleEndian;
+import java.lang.ref.WeakReference;
+import java.util.List;
+import java.util.NoSuchElementException;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFDocumentCore;
-
import org.apache.poi.hwpf.model.CHPX;
import org.apache.poi.hwpf.model.CPSplitCalculator;
import org.apache.poi.hwpf.model.FileInformationBlock;
@@ -31,14 +32,10 @@ import org.apache.poi.hwpf.model.Propert
import org.apache.poi.hwpf.model.SEPX;
import org.apache.poi.hwpf.model.StyleSheet;
import org.apache.poi.hwpf.model.TextPiece;
-
import org.apache.poi.hwpf.sprm.CharacterSprmCompressor;
import org.apache.poi.hwpf.sprm.ParagraphSprmCompressor;
import org.apache.poi.hwpf.sprm.SprmBuffer;
-
-import java.lang.ref.WeakReference;
-import java.util.List;
-import java.util.NoSuchElementException;
+import org.apache.poi.util.LittleEndian;
/**
* This class is the central class of the HWPF object model. All properties that
@@ -882,19 +879,29 @@ public class Range { // TODO -instantiab
}
r.initAll();
+ int tableLevel = paragraph.getTableLevel();
int tableEnd = r._parEnd;
- if (r._parStart != 0 && getParagraph(r._parStart - 1).isInTable()
- && getParagraph(r._parStart - 1)._sectionEnd >= r._sectionStart) {
- throw new IllegalArgumentException("This paragraph is not the first one in the table");
- }
+ if ( r._parStart != 0 )
+ {
+ Paragraph previous = new Paragraph(
+ _paragraphs.get( r._parStart - 1 ), this );
+ if ( previous.isInTable() && //
+ previous.getTableLevel() == tableLevel //
+ && previous._sectionEnd >= r._sectionStart )
+ {
+ throw new IllegalArgumentException(
+ "This paragraph is not the first one in the table" );
+ }
+ }
- int limit = _paragraphs.size();
- for (; tableEnd < limit; tableEnd++) {
- if (!getParagraph(tableEnd).isInTable()) {
- break;
- }
- }
+ int limit = _paragraphs.size();
+ for ( ; tableEnd < limit; tableEnd++ )
+ {
+ Paragraph next = new Paragraph( _paragraphs.get( tableEnd ), this );
+ if ( !next.isInTable() || next.getTableLevel() < tableLevel )
+ break;
+ }
initAll();
if (tableEnd > _parEnd) {
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java?rev=1142877&r1=1142876&r2=1142877&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java Tue Jul 5 02:17:54 2011
@@ -92,6 +92,11 @@ public class TestWordToHtmlConverter ext
assertTrue( result.contains( "Hyperlink text" ) );
}
+ public void testInnerTable() throws Exception
+ {
+ getHtmlText( "innertable.doc" );
+ }
+
public void testPageref() throws Exception
{
String result = getHtmlText( "pageref.doc" );
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org