Author: fanningpj
Date: Sat Mar 18 00:30:58 2023
New Revision: 1908461
URL: http://svn.apache.org/viewvc?rev=1908461&view=rev
Log:
[bug-66503] Add flag for Excel 4 macros in composite documents. Thanks to M. P.
Halpin
Added:
poi/trunk/test-data/spreadsheet/66503.xls (with props)
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/BoundSheetRecord.java
poi/trunk/poi/src/test/java/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/BoundSheetRecord.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/BoundSheetRecord.java?rev=1908461&r1=1908460&r2=1908461&view=diff
==============================================================================
---
poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/BoundSheetRecord.java
(original)
+++
poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/BoundSheetRecord.java
Sat Mar 18 00:30:58 2023
@@ -39,6 +39,7 @@ public final class BoundSheetRecord exte
public static final short sid = 0x0085;
private static final BitField hiddenFlag =
BitFieldFactory.getInstance(0x01);
private static final BitField veryHiddenFlag =
BitFieldFactory.getInstance(0x02);
+ private static final BitField xl4Flag = BitFieldFactory.getInstance(0x100);
private int field_1_position_of_BOF;
private int field_2_option_flags;
@@ -187,6 +188,24 @@ public final class BoundSheetRecord exte
}
/**
+ * Is the sheet an Excel 4 macro sheet?
+ *
+ * @return {@code true} if very hidden
+ */
+ public boolean isExcel4Macro() {
+ return xl4Flag.isSet(field_2_option_flags);
+ }
+
+ /**
+ * Is the sheet an Excel 4 macro sheet?
+ *
+ * @param xl4flag {@code true} if an excel 4 macro sheet
+ */
+ public void setExcel4Macro(boolean xl4flag) {
+ field_2_option_flags = xl4Flag.setBoolean(field_2_option_flags,
xl4flag);
+ }
+
+ /**
* Converts a List of {@link BoundSheetRecord}s to an array and sorts by
the position of their
* BOFs.
*
Modified:
poi/trunk/poi/src/test/java/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java?rev=1908461&r1=1908460&r2=1908461&view=diff
==============================================================================
---
poi/trunk/poi/src/test/java/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
(original)
+++
poi/trunk/poi/src/test/java/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
Sat Mar 18 00:30:58 2023
@@ -166,4 +166,26 @@ final class TestHSSFEventFactory {
Biff8EncryptionKey.setCurrentUserPassword(null);
}
}
+
+ @Test
+ void testXL4Workbook() throws Exception {
+ // This document has a single Excel 4 macro in it
+ openSample("66503.xls");
+ assertEquals(records.stream()
+ .filter(r -> r instanceof BoundSheetRecord)
+ .map(r -> (BoundSheetRecord)r)
+ .filter(BoundSheetRecord::isExcel4Macro)
+ .count(), 1);
+ }
+
+ @Test
+ void testXL4Workbook_false() throws Exception {
+ // This document does not have an Excel 4 macro in it
+ openSample("42844.xls");
+ assertEquals(records.stream()
+ .filter(r -> r instanceof BoundSheetRecord)
+ .map(r -> (BoundSheetRecord)r)
+ .filter(BoundSheetRecord::isExcel4Macro)
+ .count(), 0);
+ }
}
Added: poi/trunk/test-data/spreadsheet/66503.xls
URL:
http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/66503.xls?rev=1908461&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/spreadsheet/66503.xls
------------------------------------------------------------------------------
svn:mime-type = application/vnd.ms-excel
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]