bug 59645: add Page Setup Print row and column headings support for Common SS

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-06-19 18:20:23 +00:00
parent 8240a8ab5d
commit 895bcab9f9
6 changed files with 140 additions and 22 deletions

View File

@ -103,6 +103,7 @@ public final class InternalSheet {
private List<RecordBase> _records;
protected PrintGridlinesRecord printGridlines = null;
protected PrintHeadersRecord printHeaders = null;
protected GridsetRecord gridset = null;
private GutsRecord _gutsRecord;
protected DefaultColWidthRecord defaultcolwidth = new DefaultColWidthRecord();
@ -313,6 +314,10 @@ public final class InternalSheet {
{
printGridlines = (PrintGridlinesRecord) rec;
}
else if ( recSid == PrintHeadersRecord.sid )
{
printHeaders = (PrintHeadersRecord) rec;
}
else if ( recSid == GridsetRecord.sid )
{
gridset = (GridsetRecord) rec;
@ -455,7 +460,8 @@ public final class InternalSheet {
records.add(createIteration() );
records.add(createDelta() );
records.add(createSaveRecalc() );
records.add(createPrintHeaders() );
printHeaders = createPrintHeaders();
records.add(printHeaders);
printGridlines = createPrintGridlines();
records.add( printGridlines );
gridset = createGridset();
@ -1344,6 +1350,24 @@ public final class InternalSheet {
{
printGridlines = newPrintGridlines;
}
/**
* Returns the PrintHeadersRecord.
* @return PrintHeadersRecord for the sheet.
*/
public PrintHeadersRecord getPrintHeaders()
{
return printHeaders;
}
/**
* Sets the PrintHeadersRecord.
* @param newPrintHeaders The new PrintHeadersRecord for the sheet.
*/
public void setPrintHeaders(PrintHeadersRecord newPrintHeaders)
{
printHeaders = newPrintHeaders;
}
/**
* Sets whether the sheet is selected
@ -1510,6 +1534,22 @@ public final class InternalSheet {
public boolean isDisplayRowColHeadings() {
return windowTwo.getDisplayRowColHeadings();
}
/**
* Sets whether the RowColHeadings are shown in a viewer.
* @param show whether to show RowColHeadings or not
*/
public void setPrintRowColHeadings(boolean show) {
windowTwo.setDisplayRowColHeadings(show);
}
/**
* Returns if RowColHeadings are displayed.
* @return whether RowColHeadings are displayed
*/
public boolean isPrintRowColHeadings() {
return windowTwo.getDisplayRowColHeadings();
}
/**

View File

@ -1199,12 +1199,33 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
/**
* Turns on or off the printing of gridlines.
*
* @param newPrintGridlines boolean to turn on or off the printing of
* @param show boolean to turn on or off the printing of
* gridlines
*/
@Override
public void setPrintGridlines(boolean newPrintGridlines) {
getSheet().getPrintGridlines().setPrintGridlines(newPrintGridlines);
public void setPrintGridlines(boolean show) {
getSheet().getPrintGridlines().setPrintGridlines(show);
}
/**
* Returns whether row and column headings are printed.
*
* @return row and column headings are printed
*/
@Override
public boolean isPrintRowAndColumnHeadings() {
return getSheet().getPrintHeaders().getPrintHeaders();
}
/**
* Turns on or off the printing of row and column headings.
*
* @param show boolean to turn on or off the printing of
* row and column headings
*/
@Override
public void setPrintRowAndColumnHeadings(boolean show) {
getSheet().getPrintHeaders().setPrintHeaders(show);
}
/**

View File

@ -511,21 +511,35 @@ public interface Sheet extends Iterable<Row> {
* Gets the flag indicating whether this sheet displays the lines
* between rows and columns to make editing and reading easier.
*
* @return <code>true</code> if this sheet displays gridlines.
* @see #isPrintGridlines() to check if printing of gridlines is turned on or off
* @return <code>true</code> if this sheet prints gridlines.
* @see #isDisplayGridlines() to check if gridlines are displayed on screen
*/
boolean isPrintGridlines();
/**
* Sets the flag indicating whether this sheet should display the lines
* Sets the flag indicating whether this sheet should print the lines
* between rows and columns to make editing and reading easier.
* To turn printing of gridlines use {@link #setPrintGridlines(boolean)}
*
*
* @param show <code>true</code> if this sheet should display gridlines.
* @see #setPrintGridlines(boolean)
* @param show <code>true</code> if this sheet should print gridlines.
* @see #setDisplayGridlines(boolean) to display gridlines on screen
*/
void setPrintGridlines(boolean show);
/**
* Gets the flag indicating whether this sheet prints the
* row and column headings when printing.
*
* @return <code>true</code> if this sheet prints row and column headings.
*/
boolean isPrintRowAndColumnHeadings();
/**
* Sets the flag indicating whether this sheet should print
* row and columns headings when printing.
*
* @param show <code>true</code> if this sheet should print row and column headings.
*/
void setPrintRowAndColumnHeadings(boolean show);
/**
* Gets the print setup object.

View File

@ -704,11 +704,9 @@ public class SXSSFSheet implements Sheet, Cloneable
}
/**
* Gets the flag indicating whether this sheet displays the lines
* between rows and columns to make editing and reading easier.
* Returns whether gridlines are printed.
*
* @return <code>true</code> if this sheet displays gridlines.
* @see #isPrintGridlines() to check if printing of gridlines is turned on or off
* @return whether gridlines are printed
*/
@Override
public boolean isPrintGridlines()
@ -717,19 +715,37 @@ public class SXSSFSheet implements Sheet, Cloneable
}
/**
* Sets the flag indicating whether this sheet should display the lines
* between rows and columns to make editing and reading easier.
* To turn printing of gridlines use {@link #setPrintGridlines(boolean)}
* Turns on or off the printing of gridlines.
*
*
* @param show <code>true</code> if this sheet should display gridlines.
* @see #setPrintGridlines(boolean)
* @param show boolean to turn on or off the printing of gridlines
*/
@Override
public void setPrintGridlines(boolean show)
{
_sh.setPrintGridlines(show);
}
/**
* Returns whether row and column headings are printed.
*
* @return whether row and column headings are printed
*/
@Override
public boolean isPrintRowAndColumnHeadings()
{
return _sh.isPrintRowAndColumnHeadings();
}
/**
* Turns on or off the printing of row and column headings.
*
* @param show boolean to turn on or off the printing of row and column headings
*/
@Override
public void setPrintRowAndColumnHeadings(boolean show)
{
_sh.setPrintRowAndColumnHeadings(show);
}
/**
* Gets the print setup object.

View File

@ -1757,6 +1757,29 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
opts.setGridLines(value);
}
/**
* Returns whether row and column headings are printed.
*
* @return whether row and column headings are printed
*/
@Override
public boolean isPrintRowAndColumnHeadings() {
CTPrintOptions opts = worksheet.getPrintOptions();
return opts != null && opts.getHeadings();
}
/**
* Turns on or off the printing of row and column headings.
*
* @param value boolean to turn on or off the printing of row and column headings
*/
@Override
public void setPrintRowAndColumnHeadings(boolean value) {
CTPrintOptions opts = worksheet.isSetPrintOptions() ?
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
opts.setHeadings(value);
}
/**
* Tests if there is a page break at the indicated row

View File

@ -682,7 +682,7 @@ public abstract class BaseTestSheet {
}
/**
* Test basic display properties
* Test basic display and print properties
*/
@Test
public void sheetProperties() throws IOException {
@ -704,6 +704,10 @@ public abstract class BaseTestSheet {
assertFalse(sheet.isPrintGridlines());
sheet.setPrintGridlines(true);
assertTrue(sheet.isPrintGridlines());
assertFalse(sheet.isPrintRowAndColumnHeadings());
sheet.setPrintRowAndColumnHeadings(true);
assertTrue(sheet.isPrintRowAndColumnHeadings());
assertFalse(sheet.isDisplayFormulas());
sheet.setDisplayFormulas(true);