diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index a37166aac..ac5d2f636 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -53,6 +53,8 @@ Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx + 45472 - Fixed incorrect default row height in OpenOffice 2.3 + 44692 - HSSFPicture.resize() stretched image when there was a text next to it 45543 - Optionally extract comment text with PowerPointExtractor, and initial hslf model support for comments 45538 - Include excel headers and footers in the output of ExcelExtractor 44894 - refactor duplicate logic from EventRecordFactory to RecordFactory diff --git a/src/documentation/content/xdocs/slideshow/how-to-shapes.xml b/src/documentation/content/xdocs/slideshow/how-to-shapes.xml index 7959eedaf..40ef32aa7 100644 --- a/src/documentation/content/xdocs/slideshow/how-to-shapes.xml +++ b/src/documentation/content/xdocs/slideshow/how-to-shapes.xml @@ -46,6 +46,7 @@
  • How to create shapes of arbitrary geometry
  • Shapes and Graphics2D
  • How to convert slides into images
  • +
  • Headers / Footers
  • Features @@ -620,6 +621,48 @@
    + +
    How to extract Headers / Footers from an existing presentation + + + FileInputStream is = new FileInputStream("slideshow.ppt"); + SlideShow ppt = new SlideShow(is); + is.close(); + Slide[] slides = ppt.getSlides(); + + //presentation-scope headers / footers + HeadersFooters hdd = ppt.getSlideHeadersFooters(); + if(hdd.isFooterVisible()) { + String footerText = hdd.getFooterText(); + } + + //per-slide headers / footers + for (int i=0; i < slides.length; i++){ + HeadersFooters hdd2 = slides[i].getHeadersFooters(); + if(hdd2.isFooterVisible()) { + String footerText = hdd2.getFooterText(); + } + if(hdd2.isUserDateVisible()) { + String customDate = hdd2.getDateTimeText(); + } + if(hdd2.isSlideNumberVisible()){ + int slideNUm = slides[i].getSlideNumber(); + } + + } + +
    +
    How to set Headers / Footers + + + SlideShow ppt = new SlideShow(); + + //presentation-scope headers / footers + HeadersFooters hdd = ppt.getSlideHeadersFooters(); + hdd.setSlideNumberVisible(true); + hdd.setFootersText("Created by POI-HSLF"); + +
    diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 14d942dc1..a9e1cbdc6 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -50,6 +50,8 @@ Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx
    + 45472 - Fixed incorrect default row height in OpenOffice 2.3 + 44692 - HSSFPicture.resize() stretched image when there was a text next to it 45543 - Optionally extract comment text with PowerPointExtractor, and initial hslf model support for comments 45538 - Include excel headers and footers in the output of ExcelExtractor 44894 - refactor duplicate logic from EventRecordFactory to RecordFactory diff --git a/src/java/org/apache/poi/hssf/record/RowRecord.java b/src/java/org/apache/poi/hssf/record/RowRecord.java index cbfc0ec59..46d4a1efe 100644 --- a/src/java/org/apache/poi/hssf/record/RowRecord.java +++ b/src/java/org/apache/poi/hssf/record/RowRecord.java @@ -63,8 +63,7 @@ public final class RowRecord extends Record implements Comparable { field_1_row_number = rowNumber; field_2_first_col = -1; field_3_last_col = -1; - field_4_height = (short)DEFAULT_HEIGHT_BIT; - field_4_height = (short)DEFAULT_HEIGHT_BIT; + field_4_height = (short)0xFF; field_5_optimize = ( short ) 0; field_6_reserved = ( short ) 0; field_7_option_flags = OPTION_BITS_ALWAYS_SET; // seems necessary for outlining diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java index 0ddac1f6d..9ad89c34a 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java @@ -484,7 +484,14 @@ public final class HSSFRow implements Comparable, Row { public short getHeight() { - return row.getHeight(); + short height = row.getHeight(); + + //The low-order 15 bits contain the row height. + //The 0x8000 bit indicates that the row is standard height (optional) + if ((height & 0x8000) != 0) height = sheet.getDefaultRowHeight(); + else height &= 0x7FFF; + + return height; } /** @@ -494,7 +501,7 @@ public final class HSSFRow implements Comparable, Row { public float getHeightInPoints() { - return (row.getHeight() / 20); + return ((float)getHeight() / 20); } /** diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java index 3c8f3a873..b09753bcb 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java @@ -277,4 +277,29 @@ public final class TestHSSFRow extends TestCase { assertEquals(null, row.getCell(4)); assertEquals(HSSFCell.CELL_TYPE_NUMERIC, row.getCell(5).getCellType()); } + + public void testRowHeight() { + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet(); + HSSFRow row1 = sheet.createRow( (short) 0); + + assertEquals(0xFF, row1.getHeight()); + assertEquals(sheet.getDefaultRowHeight(), row1.getHeight()); + + HSSFRow row2 = sheet.createRow( (short) 1); + row2.setHeight((short)400); + + assertEquals(400, row2.getHeight()); + + workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook); + sheet = workbook.getSheetAt(0); + + row1 = sheet.getRow(0); + assertEquals(0xFF, row1.getHeight()); + assertEquals(sheet.getDefaultRowHeight(), row1.getHeight()); + + row2 = sheet.getRow(1); + assertEquals(400, row2.getHeight()); + } + } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 6fcd38498..2c8287f4b 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -847,8 +847,8 @@ public final class TestHSSFSheet extends TestCase { } assertEquals("Hi Excel!", row.getCell(0).getRichStringCellValue().getString()); // check row height for 'default' flag - assertEquals((short)0x8000, row.getHeight()); - + assertEquals((short)0xFF, row.getHeight()); + HSSFTestDataSamples.writeOutAndReadBack(wb); } }