Skip to content

Commit 96948c6

Browse files
xzel23svanteschubert
authored andcommitted
allow method chaining for OdfTable and OdfTableCell
1 parent f141069 commit 96948c6

File tree

2 files changed

+110
-28
lines changed

2 files changed

+110
-28
lines changed

odfdom/src/main/java/org/odftoolkit/odfdom/doc/table/OdfTable.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,9 @@ public long getWidth() {
299299
* @param width the width that need to set (in Millimeter).
300300
* <p>An UnsupportedOperationException will be thrown if the table is in the spreadsheet
301301
* document.
302+
* @return this {@code OdfTable} instance
302303
*/
303-
public void setWidth(long width) {
304+
public OdfTable setWidth(long width) {
304305
if (!mIsSpreadsheet) {
305306
String sWidthMM = String.valueOf(width) + Unit.MILLIMETER.abbr();
306307
String sWidthIN = PositiveLength.mapToUnit(sWidthMM, Unit.INCH);
@@ -316,6 +317,8 @@ public void setWidth(long width) {
316317
} else {
317318
throw new UnsupportedOperationException();
318319
}
320+
321+
return this;
319322
}
320323

321324
static void setLeftTopBorderStyleProperties(OdfStyle style) {
@@ -1905,10 +1908,11 @@ public String getTableName() {
19051908
* Set the table name.
19061909
*
19071910
* @param tableName the table name
1911+
* @return this {@code OdfTable} instance
19081912
* @throws IllegalArgumentException if the tableName is duplicate with one of tables in the
19091913
* current document
19101914
*/
1911-
public void setTableName(String tableName) {
1915+
public OdfTable setTableName(String tableName) {
19121916
// check if the table name is already exist
19131917
boolean isSpreadsheet = mDocument instanceof OdfSpreadsheetDocument;
19141918
List<OdfTable> tableList = mDocument.getTableList(!isSpreadsheet);
@@ -1921,6 +1925,8 @@ public void setTableName(String tableName) {
19211925
}
19221926
}
19231927
mTableElement.setTableNameAttribute(tableName);
1928+
1929+
return this;
19241930
}
19251931

19261932
/**
@@ -1940,9 +1946,11 @@ public boolean isProtected() {
19401946
* Set if the table is protected.
19411947
*
19421948
* @param isProtected the protected attribute of the table to be set
1949+
* @return this {@code OdfTable} instance
19431950
*/
1944-
public void setProtected(boolean isProtected) {
1951+
public OdfTable setProtected(boolean isProtected) {
19451952
mTableElement.setTableProtectedAttribute(isProtected);
1953+
return this;
19461954
}
19471955

19481956
/**
@@ -1997,6 +2005,7 @@ protected boolean isCellStyleInheritance() {
19972005
* inheritance setting have no effect on them.
19982006
*
19992007
* @param isEnabled if<code>isEnabled</code> is true, cell style will be inherited by new cell.
2008+
* @return this {@code OdfTable} instance
20002009
* @see #isCellStyleInheritance()
20012010
* @see #appendColumn()
20022011
* @see #appendColumns(int)
@@ -2012,8 +2021,9 @@ protected boolean isCellStyleInheritance() {
20122021
* @see #getColumnByIndex(int)
20132022
* @see #getRowByIndex(int)
20142023
*/
2015-
public void setCellStyleInheritance(boolean isEnabled) {
2024+
public OdfTable setCellStyleInheritance(boolean isEnabled) {
20162025
mIsCellStyleInheritance = isEnabled;
2026+
return this;
20172027
}
20182028
////////////////////////////////////////////////////////////////////////////////////////////
20192029

0 commit comments

Comments
 (0)