Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreambleAppender#appendColumns : prevent systematic table:table-column=1024 #250

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion fastods-crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@
<version>1.70</version>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -90,4 +106,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void appendColumns(final XMLUtil xmlUtil, final Appendable appendable)
final Iterator<TableColumnImpl> iterator = this.model.getColumns().iterator();
if (!iterator.hasNext()) {
TableColumnImpl.DEFAULT_TABLE_COLUMN
.appendXMLToTable(xmlUtil, appendable, MAX_COLUMN_COUNT);
.appendXMLToTable(xmlUtil, appendable, this.model.getColumnCapacity());
return;
}

Expand All @@ -81,7 +81,7 @@ public void appendColumns(final XMLUtil xmlUtil, final Appendable appendable)
appendable.append("<table:table-header-columns>");
}
int count = 1;
int endCount = MAX_COLUMN_COUNT;
int endCount = this.model.getColumnCapacity();
TableColumnImpl curColumn = iterator.next(); // will be shifted to prevTCS
if (curColumn == null) {
curColumn = TableColumnImpl.DEFAULT_TABLE_COLUMN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,4 +683,8 @@ public void setHeaderColumnsCount(final int headerColumnsCount) {
public int getHeaderColumnsCount() {
return this.headerColumnsCount;
}

public int getColumnCapacity() {
return this.columnCapacity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
package com.github.jferard.fastods;


import com.github.jferard.fastods.style.TableColumnStyle;
import com.github.jferard.fastods.testlib.DomTester;
import com.github.jferard.fastods.util.FastFullList;
import com.github.jferard.fastods.util.XMLUtil;
import java.io.IOException;

import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import org.powermock.api.easymock.PowerMock;

import java.io.IOException;
import com.github.jferard.fastods.style.TableColumnStyle;
import com.github.jferard.fastods.testlib.DomTester;
import com.github.jferard.fastods.util.FastFullList;
import com.github.jferard.fastods.util.XMLUtil;

public class PreambleAppenderTest {
private PreambleAppender preambleAppender;
Expand All @@ -57,6 +58,7 @@ public void appendTenColumnsTest() throws IOException {
EasyMock.expect(this.tm.getHeaderColumnsCount()).andReturn(0);
EasyMock.expect(this.tm.getColumns())
.andReturn(FastFullList.newList(x, x, x, x, x, y, y, y, x, x));
EasyMock.expect(this.tm.getColumnCapacity()).andReturn(100);

PowerMock.replayAll();
final StringBuilder sb = new StringBuilder();
Expand All @@ -72,7 +74,7 @@ public void appendTenColumnsTest() throws IOException {
"table:number-columns-repeated=\"2\" " +
"table:default-cell-style-name=\"Default\"/>" +
"<table:table-column table:style-name=\"co1\"" +
" table:number-columns-repeated=\"1014\" " +
" table:number-columns-repeated=\"90\" " +
"table:default-cell-style-name=\"Default\"/>", sb.toString());
PowerMock.verifyAll();
}
Expand All @@ -84,13 +86,15 @@ public void appendEmptyColumnsTest() throws IOException {
PowerMock.resetAll();
EasyMock.expect(this.tm.getColumns())
.andReturn(FastFullList.<TableColumnImpl>newList());
EasyMock.expect(this.tm.getColumnCapacity())
.andReturn(42);

PowerMock.replayAll();
final StringBuilder sb = new StringBuilder();
this.preambleAppender.appendColumns(this.xmlUtil, sb);
DomTester.assertEquals(
"<table:table-column table:style-name=\"co1\"" +
" table:number-columns-repeated=\"1024\" " +
" table:number-columns-repeated=\"42\" " +
"table:default-cell-style-name=\"Default\"/>", sb.toString());
PowerMock.verifyAll();
}
Expand All @@ -103,6 +107,7 @@ public void appendMissingColumnsTest() throws IOException {
EasyMock.expect(this.tm.getHeaderColumnsCount()).andReturn(0);
EasyMock.expect(this.tm.getColumns())
.andReturn(FastFullList.newList(null, null, x));
EasyMock.expect(this.tm.getColumnCapacity()).andReturn(100);

PowerMock.replayAll();
final StringBuilder sb = new StringBuilder();
Expand All @@ -114,7 +119,7 @@ public void appendMissingColumnsTest() throws IOException {
"<table:table-column table:style-name=\"x\" " +
"table:default-cell-style-name=\"Default\"/>" +
"<table:table-column table:style-name=\"co1\" " +
"table:number-columns-repeated=\"1021\" " +
"table:number-columns-repeated=\"97\" " +
"table:default-cell-style-name=\"Default\"/>", sb.toString());
PowerMock.verifyAll();
}
Expand All @@ -128,6 +133,7 @@ public void testHeaderColumns() throws IOException {
EasyMock.expect(this.tm.getHeaderColumnsCount()).andReturn(2);
EasyMock.expect(this.tm.getColumns())
.andReturn(FastFullList.newList(x, x, x, x, x, y, y, y, x, x));
EasyMock.expect(this.tm.getColumnCapacity()).andReturn(100);

PowerMock.replayAll();
final StringBuilder sb = new StringBuilder();
Expand All @@ -148,7 +154,7 @@ public void testHeaderColumns() throws IOException {
"table:number-columns-repeated=\"2\" " +
"table:default-cell-style-name=\"Default\"/>" +
"<table:table-column table:style-name=\"co1\"" +
" table:number-columns-repeated=\"1014\" " +
" table:number-columns-repeated=\"90\" " +
"table:default-cell-style-name=\"Default\"/>", sb.toString());
PowerMock.verifyAll();
}
Expand All @@ -162,6 +168,7 @@ public void testFiveHeaderColumns() throws IOException {
EasyMock.expect(this.tm.getHeaderColumnsCount()).andReturn(5);
EasyMock.expect(this.tm.getColumns())
.andReturn(FastFullList.newList(x, x, x, x, x, y, y, y, x, x));
EasyMock.expect(this.tm.getColumnCapacity()).andReturn(100);

PowerMock.replayAll();
final StringBuilder sb = new StringBuilder();
Expand All @@ -179,7 +186,7 @@ public void testFiveHeaderColumns() throws IOException {
"table:number-columns-repeated=\"2\" " +
"table:default-cell-style-name=\"Default\"/>" +
"<table:table-column table:style-name=\"co1\"" +
" table:number-columns-repeated=\"1014\" " +
" table:number-columns-repeated=\"90\" " +
"table:default-cell-style-name=\"Default\"/>", sb.toString());
PowerMock.verifyAll();
}
Expand All @@ -193,6 +200,7 @@ public void testTenHeaderColumns() throws IOException {
EasyMock.expect(this.tm.getHeaderColumnsCount()).andReturn(10);
EasyMock.expect(this.tm.getColumns())
.andReturn(FastFullList.newList(x, x, x, x, x, y, y, y, x, x));
EasyMock.expect(this.tm.getColumnCapacity()).andReturn(100);

PowerMock.replayAll();
final StringBuilder sb = new StringBuilder();
Expand All @@ -210,7 +218,7 @@ public void testTenHeaderColumns() throws IOException {
"table:default-cell-style-name=\"Default\"/>" +
"</table:table-header-columns>" +
"<table:table-column table:style-name=\"co1\"" +
" table:number-columns-repeated=\"1014\" " +
" table:number-columns-repeated=\"90\" " +
"table:default-cell-style-name=\"Default\"/>", sb.toString());
PowerMock.verifyAll();
}
Expand All @@ -224,6 +232,7 @@ public void testElevenHeaderColumns() throws IOException {
EasyMock.expect(this.tm.getHeaderColumnsCount()).andReturn(11);
EasyMock.expect(this.tm.getColumns())
.andReturn(FastFullList.newList(x, x, x, x, x, y, y, y, x, x));
EasyMock.expect(this.tm.getColumnCapacity()).andReturn(100);

PowerMock.replayAll();
final StringBuilder sb = new StringBuilder();
Expand All @@ -243,7 +252,7 @@ public void testElevenHeaderColumns() throws IOException {
"table:default-cell-style-name=\"Default\"/>" +
"</table:table-header-columns>" +
"<table:table-column table:style-name=\"co1\" " +
"table:number-columns-repeated=\"1013\" " +
"table:number-columns-repeated=\"89\" " +
"table:default-cell-style-name=\"Default\"/>", sb.toString());
PowerMock.verifyAll();
}
Expand Down
Loading