add non-deprecated method insertTableBefore to Range
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1155214 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
653bf768e8
commit
8b6d31c903
@ -563,17 +563,18 @@ public class Range { // TODO -instantiable superclass
|
|||||||
adjustFIB(-(_end - _start));
|
adjustFIB(-(_end - _start));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a simple table into the beginning of this range. The number of
|
* Inserts a simple table into the beginning of this range. The number of
|
||||||
* columns is determined by the TableProperties passed into this function.
|
* columns is determined by the TableProperties passed into this function.
|
||||||
*
|
*
|
||||||
* @param props
|
* @param props
|
||||||
* The table properties for the table.
|
* The table properties for the table.
|
||||||
* @param rows
|
* @param rows
|
||||||
* The number of rows.
|
* The number of rows.
|
||||||
* @return The empty Table that is now part of the document.
|
* @return The empty Table that is now part of the document.
|
||||||
* @deprecated Use code shall not work with {@link TableProperties}
|
* @deprecated Use code shall not work with {@link TableProperties}. Use
|
||||||
*/
|
* {@link #insertTableBefore(short, int)} instead
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Table insertBefore(TableProperties props, int rows) {
|
public Table insertBefore(TableProperties props, int rows) {
|
||||||
ParagraphProperties parProps = new ParagraphProperties();
|
ParagraphProperties parProps = new ParagraphProperties();
|
||||||
@ -603,6 +604,42 @@ public class Range { // TODO -instantiable superclass
|
|||||||
return new Table( _start, _start + diff, this, 1 );
|
return new Table( _start, _start + diff, this, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts a simple table into the beginning of this range.
|
||||||
|
*
|
||||||
|
* @param columns
|
||||||
|
* The number of columns
|
||||||
|
* @param rows
|
||||||
|
* The number of rows.
|
||||||
|
* @return The empty Table that is now part of the document.
|
||||||
|
*/
|
||||||
|
public Table insertTableBefore(short columns, int rows) {
|
||||||
|
ParagraphProperties parProps = new ParagraphProperties();
|
||||||
|
parProps.setFInTable(true);
|
||||||
|
parProps.setItap( 1 );
|
||||||
|
|
||||||
|
final int oldEnd = this._end;
|
||||||
|
|
||||||
|
for ( int x = 0; x < rows; x++ )
|
||||||
|
{
|
||||||
|
Paragraph cell = this.insertBefore( parProps, StyleSheet.NIL_STYLE );
|
||||||
|
cell.insertAfter( String.valueOf( '\u0007' ) );
|
||||||
|
for ( int y = 1; y < columns; y++ )
|
||||||
|
{
|
||||||
|
cell = cell.insertAfter( parProps, StyleSheet.NIL_STYLE );
|
||||||
|
cell.insertAfter( String.valueOf( '\u0007' ) );
|
||||||
|
}
|
||||||
|
cell = cell.insertAfter( parProps, StyleSheet.NIL_STYLE,
|
||||||
|
String.valueOf( '\u0007' ) );
|
||||||
|
cell.setTableRowEnd( new TableProperties( columns ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
final int newEnd = this._end;
|
||||||
|
final int diff = newEnd - oldEnd;
|
||||||
|
|
||||||
|
return new Table( _start, _start + diff, this, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a list into the beginning of this range.
|
* Inserts a list into the beginning of this range.
|
||||||
*
|
*
|
||||||
|
@ -94,8 +94,7 @@ public class TestBugs extends TestCase
|
|||||||
HWPFDocument doc = HWPFTestDataSamples.openSampleFile( "empty.doc" );
|
HWPFDocument doc = HWPFTestDataSamples.openSampleFile( "empty.doc" );
|
||||||
|
|
||||||
Range range = doc.getRange();
|
Range range = doc.getRange();
|
||||||
Table table = range.insertBefore(
|
Table table = range.insertTableBefore( (short) columns, rows );
|
||||||
new TableProperties( (short) columns ), rows );
|
|
||||||
table.sanityCheck();
|
table.sanityCheck();
|
||||||
range.sanityCheck();
|
range.sanityCheck();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user