poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1846931 - in /poi/trunk: ./ src/integrationtest/org/apache/poi/ src/ooxml/java/org/apache/poi/ooxml/extractor/ src/ooxml/testcases/org/apache/poi/extractor/ooxml/ src/ooxml/testcases/org/apache/poi/poifs/crypt/ src/ooxml/testcases/org/apac...
Date Mon, 19 Nov 2018 18:00:42 GMT
Author: kiwiwings
Date: Mon Nov 19 18:00:42 2018
New Revision: 1846931

URL: http://svn.apache.org/viewvc?rev=1846931&view=rev
Log:
Remove/Minimize references to Scratchpad module from other modules

Modified:
    poi/trunk/build.xml
    poi/trunk/src/integrationtest/org/apache/poi/BaseIntegrationTest.java
    poi/trunk/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestHeadersFooters.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestEmbedOLEPackage.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
    poi/trunk/src/scratchpad/src/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java

Modified: poi/trunk/build.xml
URL: http://svn.apache.org/viewvc/poi/trunk/build.xml?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/build.xml (original)
+++ poi/trunk/build.xml Mon Nov 19 18:00:42 2018
@@ -1133,6 +1133,7 @@ under the License.
             <classpath>
                 <path refid="ooxml.classpath"/>
                 <pathelement path="${ooxml.output.dir}"/>
+                <pathelement location="${scratchpad.output.dir}"/>
             </classpath>
         </javac>
         <copy todir="${examples.output.dir}">
@@ -1303,6 +1304,7 @@ under the License.
                 <pathelement location="${main.output.test.dir}"/>
                 <pathelement location="${examples.output.dir}"/>
                 <pathelement location="${main.ant.jar}"/>
+                <pathelement location="${scratchpad.output.dir}"/>
             </classpath>
         </javac>
         <!--copy todir="${integration.output.dir}">

Modified: poi/trunk/src/integrationtest/org/apache/poi/BaseIntegrationTest.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/BaseIntegrationTest.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/BaseIntegrationTest.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/BaseIntegrationTest.java Mon Nov 19 18:00:42
2018
@@ -16,17 +16,24 @@
 ==================================================================== */
 package org.apache.poi;
 
-import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
-import org.apache.poi.hssf.OldExcelFormatException;
-import org.apache.poi.hwpf.OldWordFileFormatException;
-import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
-import org.apache.poi.stress.*;
-import org.junit.Assume;
+import static org.junit.Assert.assertNotNull;
 
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.zip.ZipException;
 
-import static org.junit.Assert.assertNotNull;
+import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
+import org.apache.poi.stress.FileHandler;
+import org.apache.poi.stress.HSLFFileHandler;
+import org.apache.poi.stress.HSSFFileHandler;
+import org.apache.poi.stress.HWPFFileHandler;
+import org.apache.poi.stress.XSLFFileHandler;
+import org.apache.poi.stress.XSSFFileHandler;
+import org.apache.poi.stress.XWPFFileHandler;
+import org.junit.Assume;
 
 public class BaseIntegrationTest {
 	private final File rootDir;
@@ -53,12 +60,13 @@ public class BaseIntegrationTest {
 
         	// use XWPF instead of HWPF and XSSF instead of HSSF as the file seems to have the
wrong extension
 			handleWrongExtension(inputFile, e);
-		} catch (OldWordFileFormatException | OldExcelFormatException | OldPowerPointFormatException
e) {
-        	// at least perform extracting tests on these old files
         } catch (OldFileFormatException e) {
-            // Not even text extraction is supported for these: handler.handleExtracting(inputFile);
-			//noinspection ConstantConditions
-			Assume.assumeFalse("File " + file + " excluded because it is unsupported old Excel format",
true);
+        	if (e.getClass().equals(OldFileFormatException.class)) {
+				// Not even text extraction is supported for these: handler.handleExtracting(inputFile);
+				//noinspection ConstantConditions
+				Assume.assumeFalse("File " + file + " excluded because it is unsupported old Excel format",
true);
+			}
+			// otherwise try at least to perform extracting tests on these old files
         } catch (EncryptedDocumentException e) {
         	// Do not try to read encrypted files
 			//noinspection ConstantConditions

Modified: poi/trunk/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java Mon Nov
19 18:00:42 2018
@@ -16,24 +16,20 @@
 ==================================================================== */
 package org.apache.poi.ooxml.extractor;
 
-import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.poi.EncryptedDocumentException;
+import org.apache.poi.extractor.OLE2ExtractorFactory;
 import org.apache.poi.extractor.POIOLE2TextExtractor;
 import org.apache.poi.extractor.POITextExtractor;
-import org.apache.poi.extractor.OLE2ExtractorFactory;
-import org.apache.poi.hsmf.MAPIMessage;
-import org.apache.poi.hsmf.datatypes.AttachmentChunks;
-import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
 import org.apache.poi.hssf.extractor.ExcelExtractor;
 import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
-import org.apache.poi.hwpf.extractor.WordExtractor;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackageAccess;
@@ -46,9 +42,9 @@ import org.apache.poi.poifs.filesystem.D
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.Entry;
 import org.apache.poi.poifs.filesystem.FileMagic;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.poifs.filesystem.NotOLE2FileException;
 import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.sl.extractor.SlideShowExtractor;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.NotImplemented;
@@ -311,6 +307,7 @@ public final class ExtractorFactory {
             throw new IllegalStateException("The extractor didn't know which POIFS it came
from!");
         }
 
+        // provide ExcelExtractor also in OOXML module, because scratchpad is not necessary
for it
         if (ext instanceof ExcelExtractor) {
             // These are in MBD... under the root
             Iterator<Entry> it = root.getEntries();
@@ -320,34 +317,14 @@ public final class ExtractorFactory {
                     dirs.add(entry);
                 }
             }
-        } else if (ext instanceof WordExtractor) {
-            // These are in ObjectPool -> _... under the root
+        } else {
             try {
-                DirectoryEntry op = (DirectoryEntry) root.getEntry("ObjectPool");
-                Iterator<Entry> it = op.getEntries();
-                while (it.hasNext()) {
-                    Entry entry = it.next();
-                    if (entry.getName().startsWith("_")) {
-                        dirs.add(entry);
-                    }
-                }
-            } catch (FileNotFoundException e) {
-                logger.log(POILogger.INFO, "Ignoring FileNotFoundException while extracting
Word document", e.getLocalizedMessage());
-                // ignored here
-            }
-        //} else if(ext instanceof PowerPointExtractor) {
-            // Tricky, not stored directly in poifs
-            // TODO
-        } else if (ext instanceof OutlookTextExtactor) {
-            // Stored in the Attachment blocks
-            MAPIMessage msg = ((OutlookTextExtactor)ext).getMAPIMessage();
-            for (AttachmentChunks attachment : msg.getAttachmentFiles()) {
-                if (attachment.getAttachData() != null) {
-                    byte[] data = attachment.getAttachData().getValue();
-                    nonPOIFS.add( new ByteArrayInputStream(data) );
-                } else if (attachment.getAttachmentDirectory() != null) {
-                    dirs.add(attachment.getAttachmentDirectory().getDirectory());
-                }
+                Class<?> clazz = Class.forName("org.apache.poi.extractor.ole2.OLE2ScratchpadExtractorFactory");
+                Method m = clazz.getDeclaredMethod("identifyEmbeddedResources", POIOLE2TextExtractor.class,
List.class, List.class);
+                m.invoke(null, ext, dirs, nonPOIFS);
+            } catch (ReflectiveOperationException e) {
+                logger.log(POILogger.WARN, "POI Scratchpad jar not included ", e.getLocalizedMessage());
+                return new POITextExtractor[0];
             }
         }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
Mon Nov 19 18:00:42 2018
@@ -33,27 +33,18 @@ import org.apache.poi.POIDataSamples;
 import org.apache.poi.UnsupportedFileFormatException;
 import org.apache.poi.extractor.POIOLE2TextExtractor;
 import org.apache.poi.extractor.POITextExtractor;
-import org.apache.poi.hdgf.extractor.VisioTextExtractor;
-import org.apache.poi.hpbf.extractor.PublisherTextExtractor;
-import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.OldExcelFormatException;
 import org.apache.poi.hssf.extractor.EventBasedExcelExtractor;
 import org.apache.poi.hssf.extractor.ExcelExtractor;
-import org.apache.poi.hwpf.extractor.Word6Extractor;
-import org.apache.poi.hwpf.extractor.WordExtractor;
 import org.apache.poi.ooxml.extractor.ExtractorFactory;
 import org.apache.poi.ooxml.extractor.POIXMLTextExtractor;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.sl.extractor.SlideShowExtractor;
-import org.apache.poi.xdgf.extractor.XDGFVisioExtractor;
-import org.apache.poi.xssf.extractor.XSSFBEventBasedExcelExtractor;
 import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
 import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
-import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
 import org.apache.xmlbeans.XmlException;
 import org.junit.Test;
 
@@ -108,21 +99,21 @@ public class TestExtractorFactory {
     }
 
     private static final Object[] TEST_SET = {
-        "Excel", xls, ExcelExtractor.class, 200,
-        "Excel - xlsx", xlsx, XSSFExcelExtractor.class, 200,
-        "Excel - xltx", xltx, XSSFExcelExtractor.class, -1,
-        "Excel - xlsb", xlsb, XSSFBEventBasedExcelExtractor.class, -1,
-        "Word", doc, WordExtractor.class, 120,
-        "Word - docx", docx, XWPFWordExtractor.class, 120,
-        "Word - dotx", dotx, XWPFWordExtractor.class, -1,
-        "Word 6", doc6, Word6Extractor.class, 20,
-        "Word 95", doc95, Word6Extractor.class, 120,
-        "PowerPoint", ppt, SlideShowExtractor.class, 120,
-        "PowerPoint - pptx", pptx, SlideShowExtractor.class, 120,
-        "Visio", vsd, VisioTextExtractor.class, 50,
-        "Visio - vsdx", vsdx, XDGFVisioExtractor.class, 20,
-        "Publisher", pub, PublisherTextExtractor.class, 50,
-        "Outlook msg", msg, OutlookTextExtactor.class, 50,
+        "Excel", xls, "ExcelExtractor", 200,
+        "Excel - xlsx", xlsx, "XSSFExcelExtractor", 200,
+        "Excel - xltx", xltx, "XSSFExcelExtractor", -1,
+        "Excel - xlsb", xlsb, "XSSFBEventBasedExcelExtractor", -1,
+        "Word", doc, "WordExtractor", 120,
+        "Word - docx", docx, "XWPFWordExtractor", 120,
+        "Word - dotx", dotx, "XWPFWordExtractor", -1,
+        "Word 6", doc6, "Word6Extractor", 20,
+        "Word 95", doc95, "Word6Extractor", 120,
+        "PowerPoint", ppt, "SlideShowExtractor", 120,
+        "PowerPoint - pptx", pptx, "SlideShowExtractor", 120,
+        "Visio", vsd, "VisioTextExtractor", 50,
+        "Visio - vsdx", vsdx, "XDGFVisioExtractor", 20,
+        "Publisher", pub, "PublisherTextExtractor", 50,
+        "Outlook msg", msg, "OutlookTextExtactor", 50,
 
         // TODO Support OOXML-Strict, see bug #57699
         // xlsxStrict
@@ -138,7 +129,7 @@ public class TestExtractorFactory {
     public void testFile() throws Exception {
         for (int i = 0; i < TEST_SET.length; i += 4) {
             try (POITextExtractor ext = ExtractorFactory.createExtractor((File) TEST_SET[i
+ 1])) {
-                testExtractor(ext, (String) TEST_SET[i], (Class) TEST_SET[i + 2], (Integer)
TEST_SET[i + 3]);
+                testExtractor(ext, (String) TEST_SET[i], (String) TEST_SET[i + 2], (Integer)
TEST_SET[i + 3]);
             }
         }
     }
@@ -180,15 +171,15 @@ public class TestExtractorFactory {
             }
             try (FileInputStream fis = new FileInputStream(testFile);
                  POITextExtractor ext = poifsIS.apply(fis)) {
-                testExtractor(ext, (String) TEST_SET[i], (Class) TEST_SET[i + 2], (Integer)
TEST_SET[i + 3]);
+                testExtractor(ext, (String) TEST_SET[i], (String) TEST_SET[i + 2], (Integer)
TEST_SET[i + 3]);
             } catch (IllegalArgumentException e) {
                 fail("failed to process "+testFile);
             }
         }
     }
 
-    private void testExtractor(final POITextExtractor ext, final String testcase, final Class
extrClass, final Integer minLength) {
-        assertTrue("invalid extractor for " + testcase, extrClass.isInstance(ext));
+    private void testExtractor(final POITextExtractor ext, final String testcase, final String
extrClass, final Integer minLength) {
+        assertEquals("invalid extractor for " + testcase, extrClass, ext.getClass().getSimpleName());
         final String actual = ext.getText();
         if (minLength == -1) {
             assertContains(actual.toLowerCase(Locale.ROOT), "test");
@@ -215,7 +206,7 @@ public class TestExtractorFactory {
 
             try (final OPCPackage pkg = OPCPackage.open(testFile, PackageAccess.READ);
                  final POITextExtractor ext = ExtractorFactory.createExtractor(pkg)) {
-                testExtractor(ext, (String) TEST_SET[i], (Class) TEST_SET[i + 2], (Integer)
TEST_SET[i + 3]);
+                testExtractor(ext, (String) TEST_SET[i], (String) TEST_SET[i + 2], (Integer)
TEST_SET[i + 3]);
                 pkg.revert();
             }
         }
@@ -334,16 +325,22 @@ public class TestExtractorFactory {
                 int numWord = 0, numXls = 0, numPpt = 0, numMsg = 0, numWordX = 0;
                 for (POITextExtractor embed : embeds) {
                     assertTrue(embed.getText().length() > 20);
-                    if (embed instanceof SlideShowExtractor) {
-                        numPpt++;
-                    } else if (embed instanceof ExcelExtractor) {
-                        numXls++;
-                    } else if (embed instanceof WordExtractor) {
-                        numWord++;
-                    } else if (embed instanceof OutlookTextExtactor) {
-                        numMsg++;
-                    } else if (embed instanceof XWPFWordExtractor) {
-                        numWordX++;
+                    switch (embed.getClass().getSimpleName()) {
+                        case "SlideShowExtractor":
+                            numPpt++;
+                            break;
+                        case "ExcelExtractor":
+                            numXls++;
+                            break;
+                        case "WordExtractor":
+                            numWord++;
+                            break;
+                        case "OutlookTextExtactor":
+                            numMsg++;
+                            break;
+                        case "XWPFWordExtractor":
+                            numWordX++;
+                            break;
                     }
                 }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java Mon Nov
19 18:00:42 2018
@@ -23,6 +23,7 @@ import static org.apache.poi.POIDataSamp
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -35,9 +36,8 @@ import java.util.Collection;
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.POIDocument;
 import org.apache.poi.extractor.POITextExtractor;
-import org.apache.poi.ooxml.extractor.ExtractorFactory;
-import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
 import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
+import org.apache.poi.ooxml.extractor.ExtractorFactory;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptionHeader;
 import org.apache.poi.poifs.storage.RawDataUtil;
@@ -64,21 +64,24 @@ public class TestHxxFEncryption {
 
     @Parameters(name="{1}")
     public static Collection<Object[]> data() throws IOException {
+        final String base64 =
+            "H4sIAAAAAAAAAF1Uu24bMRDs/RULVwkgCUhSpHaZwkDgpHJH8fZ0G/Nx4ZI6y13yG/mRfIb9R5mlZFlIpdPtcnZmdnjPf57/vvx6+f3h6obuv3"+
+            "ylbY5bEiVHe1fEpUp5pOgkrK0iabehm7FyoZi1ks8xcvHiQu8h5bLnorTlnUvkJ/YPOHKsLVInAqCs91KakuaxLq4w3g00SgCo9Xou1UnCmSBe"+
+            "MhpRY6qHmXVFteQfQJ5yUaaOw4qXwgPVjPGAqhNH5bBHAfTmwqqoSkLdFT/J3nC0eZBRk7yiu5s7yoU+r+9l3tDtm5A3jgt6AQxNOY2ya+U4sK"+
+            "XZ+YczbpfSVVuzFOuunKraqIVD2ND3yVXauT3TNthR/O3IJAM7gzTOGeIcXZvj14ahotW8wSognlMu0Yyp/Fi7O6s+CK6haUUjtPCji7MVcgqH"+
+            "jh+42tqeqPDMroJ/lBAE4AZbJbJu6Fu35ej42Tw9mYeTwVXoBKJiPeFV94q2rZJAyNEPo/qOdWYLBpq3B2JX8GDZeJ14mZf3tOQWBmpd9yQ7kI"+
+            "DCY/jmkj1oGOicFy62r9vutC5uJsVEMFgmAXXfYcC6BRBKNHCybALFJolnrDcPXNLl+K60Vctt09YZT7YgbeOICGJ/ZgC2JztOnm1JhX3eJXni"+
+            "U5Bqhezzlu334vD/Ajr3yDGXw5G9IZ6aLmLfQafY42N3J7cjj1LaXOHihSrcC5ThmuYIB5FX5AU8tKlnNG9Dn1EnsdD4KcnPhsSNPRiXtz461b"+
+            "VZw8Pm6vn0afh4fvr0D5P/+cMuBAAA";
+        final String x = new String(RawDataUtil.decompress(base64), StandardCharsets.UTF_8);
+
         return Arrays.asList(
             // binary rc4
             new Object[]{ getDocumentInstance(), "password_tika_binaryrc4.doc", "tika", "This
is an encrypted Word 2007 File." },
             // cryptoapi
             new Object[]{ getDocumentInstance(), "password_password_cryptoapi.doc", "password",
"This is a test" },
             // binary rc4
-            new Object[]{ getSpreadSheetInstance(), "password.xls", "password",
-                x("H4sIAAAAAAAAAF1Uu24bMRDs/RULVwkgCUhSpHaZwkDgpHJH8fZ0G/Nx4ZI6y13yG/mRfIb9R5mlZFlIpdPtcnZmdnjPf57/vvx6+f3h6obuv3"+
-                  "ylbY5bEiVHe1fEpUp5pOgkrK0iabehm7FyoZi1ks8xcvHiQu8h5bLnorTlnUvkJ/YPOHKsLVInAqCs91KakuaxLq4w3g00SgCo9Xou1UnCmSBe"+
-                  "MhpRY6qHmXVFteQfQJ5yUaaOw4qXwgPVjPGAqhNH5bBHAfTmwqqoSkLdFT/J3nC0eZBRk7yiu5s7yoU+r+9l3tDtm5A3jgt6AQxNOY2ya+U4sK"+
-                  "XZ+YczbpfSVVuzFOuunKraqIVD2ND3yVXauT3TNthR/O3IJAM7gzTOGeIcXZvj14ahotW8wSognlMu0Yyp/Fi7O6s+CK6haUUjtPCji7MVcgqH"+
-                  "jh+42tqeqPDMroJ/lBAE4AZbJbJu6Fu35ej42Tw9mYeTwVXoBKJiPeFV94q2rZJAyNEPo/qOdWYLBpq3B2JX8GDZeJ14mZf3tOQWBmpd9yQ7kI"+
-                  "DCY/jmkj1oGOicFy62r9vutC5uJsVEMFgmAXXfYcC6BRBKNHCybALFJolnrDcPXNLl+K60Vctt09YZT7YgbeOICGJ/ZgC2JztOnm1JhX3eJXni"+
-                  "U5Bqhezzlu334vD/Ajr3yDGXw5G9IZ6aLmLfQafY42N3J7cjj1LaXOHihSrcC5ThmuYIB5FX5AU8tKlnNG9Dn1EnsdD4KcnPhsSNPRiXtz461b"+
-                  "VZw8Pm6vn0afh4fvr0D5P/+cMuBAAA") },
+            new Object[]{ getSpreadSheetInstance(), "password.xls", "password", x },
             // cryptoapi
             new Object[]{ getSpreadSheetInstance(), "35897-type4.xls", "freedom", "Sheet1\nhello
there!" },
             // cryptoapi (PPT only supports cryptoapi...)
@@ -86,10 +89,6 @@ public class TestHxxFEncryption {
         );
     }
 
-    private static String x(String base64) throws IOException {
-        return new String(RawDataUtil.decompress(base64), StandardCharsets.UTF_8);
-    }
-    
     @Test
     public void extract() throws IOException, OpenXML4JException, XmlException {
         File f = sampleDir.getFile(file);
@@ -112,7 +111,7 @@ public class TestHxxFEncryption {
         newPassword(null);
     }
     
-    public void newPassword(String newPass) throws IOException, OpenXML4JException, XmlException
{
+    private void newPassword(String newPass) throws IOException, OpenXML4JException, XmlException
{
         File f = sampleDir.getFile(file);
         Biff8EncryptionKey.setCurrentUserPassword(password);
         try (POITextExtractor te1 = ExtractorFactory.createExtractor(f)) {
@@ -156,10 +155,14 @@ public class TestHxxFEncryption {
             try (POITextExtractor te3 = ExtractorFactory.createExtractor(new ByteArrayInputStream(bos.toByteArray()));
                  POIDocument doc = (POIDocument) te3.getDocument()) {
                 // need to cache data (i.e. read all data) before changing the key size
-                if (doc instanceof HSLFSlideShowImpl) {
-                    HSLFSlideShowImpl hss = (HSLFSlideShowImpl) doc;
-                    hss.getPictureData();
-                    hss.getDocumentSummaryInformation();
+                Class<?> clazz = doc.getClass();
+                if ("HSLFSlideShowImpl".equals(clazz.getSimpleName())) {
+                    try {
+                        clazz.getDeclaredMethod("getPictureData").invoke(doc);
+                    } catch (ReflectiveOperationException e) {
+                        fail("either scratchpad jar is included and this should work or the
clazz should be != HSLFSlideShowImpl");
+                    }
+                    doc.getDocumentSummaryInformation();
                 }
                 EncryptionInfo ei = doc.getEncryptionInfo();
                 assertNotNull(ei);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java Mon Nov 19 18:00:42 2018
@@ -38,7 +38,6 @@ import java.util.Map;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.common.usermodel.fonts.FontGroup;
-import org.apache.poi.hslf.usermodel.HSLFSlideShow;
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.Drawable;
 import org.apache.poi.sl.usermodel.Slide;
@@ -93,9 +92,9 @@ public class TestFonts {
     }
 
     @Test
-    public void resizeToFitTextHSLF() throws IOException {
+    public void resizeToFitTextHSLF() throws IOException, ReflectiveOperationException {
         assumeFalse(xslfOnly());
-        SlideShow<?,?> ppt = new HSLFSlideShow();
+        SlideShow<?,?> ppt = (SlideShow<?,?>)Class.forName("org.apache.poi.hslf.usermodel.HSLFSlideShow").newInstance();
         resizeToFitText(ppt);
         ppt.close();
     }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestHeadersFooters.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestHeadersFooters.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestHeadersFooters.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestHeadersFooters.java Mon Nov 19 18:00:42
2018
@@ -20,19 +20,12 @@
 package org.apache.poi.sl;
 
 import static org.apache.poi.sl.SLCommonUtils.openSampleSlideshow;
-import static org.apache.poi.sl.SLCommonUtils.xslfOnly;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeFalse;
 
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.poi.hslf.model.HeadersFooters;
-import org.apache.poi.hslf.usermodel.HSLFSlide;
-import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
 import org.apache.poi.sl.usermodel.Shape;
 import org.apache.poi.sl.usermodel.Slide;
 import org.apache.poi.sl.usermodel.SlideShow;
@@ -42,33 +35,6 @@ import org.junit.Test;
 
 public class TestHeadersFooters {
     @Test
-    public void bug58144a() throws IOException {
-        assumeFalse(xslfOnly());
-        SlideShow<?,?> ppt = openSampleSlideshow("bug58144-headers-footers-2003.ppt");
-        HSLFSlide sl = (HSLFSlide)ppt.getSlides().get(0);
-        HeadersFooters hfs = sl.getHeadersFooters();
-        assertNull(hfs.getHeaderText());
-        assertEquals("Confidential", hfs.getFooterText());
-        List<List<HSLFTextParagraph>> llp = sl.getTextParagraphs();
-        assertEquals("Test", HSLFTextParagraph.getText(llp.get(0)));
-        assertFalse(llp.get(0).get(0).isHeaderOrFooter());
-        ppt.close();
-    }
-    
-    @Test
-    public void bug58144b() throws IOException {
-        assumeFalse(xslfOnly());
-        SlideShow<?,?> ppt = openSampleSlideshow("bug58144-headers-footers-2007.ppt");
-        Slide<?,?> sl =  ppt.getSlides().get(0);
-        HeadersFooters hfs2 = ((HSLFSlide)sl).getHeadersFooters();
-        assertNull(hfs2.getHeaderText());
-        assertEquals("Slide footer", hfs2.getFooterText());
-
-        testSlideShow(ppt);
-        ppt.close();
-    }
-    
-    @Test
     public void bug58144c() throws IOException {
         SlideShow<?,?> ppt = openSampleSlideshow("bug58144-headers-footers-2007.pptx");
         testSlideShow(ppt);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java Mon Nov 19 18:00:42
2018
@@ -35,13 +35,14 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collection;
 
 import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.POIDocument;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.poifs.storage.RawDataUtil;
 import org.apache.poi.sl.usermodel.ObjectMetaData;
@@ -124,7 +125,7 @@ public class TestOleShape {
     }
     
     @Test
-    public void embedData() throws IOException, InvalidFormatException {
+    public void embedData() throws IOException, InvalidFormatException, ReflectiveOperationException
{
         final ByteArrayInputStream pptBytes;
         try (SlideShow<?,?> ppt = createSlideShow()) {
             final PictureData picData = ppt.addPicture(pictureFile,  PictureType.EMF);
@@ -146,12 +147,12 @@ public class TestOleShape {
         }
     }
     
-    private SlideShow<?,?> createSlideShow() {
+    private SlideShow<?,?> createSlideShow() throws ReflectiveOperationException {
         if (api == Api.XSLF) {
             return new XMLSlideShow();
         } else {
             assumeFalse(xslfOnly());
-            return new HSLFSlideShow();
+            return (SlideShow<?,?>)Class.forName("org.apache.poi.hslf.usermodel.HSLFSlideShow").newInstance();
         }
     }
 
@@ -186,7 +187,7 @@ public class TestOleShape {
         }
     }
     
-    private void validateOleData(final InputStream in) throws IOException, InvalidFormatException
{
+    private void validateOleData(final InputStream in) throws IOException, InvalidFormatException,
ReflectiveOperationException {
         switch (app) {
         case EXCEL_V8:
         case EXCEL_V12:
@@ -195,8 +196,11 @@ public class TestOleShape {
             }
             break;
         case WORD_V8:
-            try (HWPFDocument doc = new HWPFDocument(in)) {
-                assertEquals("This is a simple file created with Word 97-SR2.\r", doc.getDocumentText());
+            Class<? extends POIDocument> clazz = (Class<? extends POIDocument>)Class.forName("org.apache.poi.hwpf.HWPFDocument");
+            Constructor<? extends POIDocument> con = clazz.getDeclaredConstructor(InputStream.class);
+            Method m = clazz.getMethod("getDocumentText");
+            try (POIDocument doc = con.newInstance(in)) {
+                assertEquals("This is a simple file created with Word 97-SR2.\r", m.invoke(doc));
             }
             break;
         case WORD_V12:

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java Mon Nov 19 18:00:42 2018
@@ -29,7 +29,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.poi.hslf.usermodel.HSLFSlideShow;
 import org.apache.poi.sl.usermodel.SlideShow;
 import org.apache.poi.sl.usermodel.SlideShowFactory;
 import org.apache.poi.xslf.usermodel.XMLSlideShow;
@@ -38,9 +37,9 @@ import org.junit.Test;
 public class TestSlide {
 
     @Test
-    public void hideHSLF() throws IOException {
+    public void hideHSLF() throws IOException, ReflectiveOperationException {
         assumeFalse(xslfOnly());
-        SlideShow<?,?> ppt1 = new HSLFSlideShow();
+        SlideShow<?,?> ppt1 = (SlideShow<?,?>)Class.forName("org.apache.poi.hslf.usermodel.HSLFSlideShow").newInstance();
         hideSlide(ppt1);
         ppt1.close();
     }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java Mon Nov 19 18:00:42 2018
@@ -34,7 +34,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.poi.hslf.usermodel.HSLFSlideShow;
 import org.apache.poi.sl.usermodel.Slide;
 import org.apache.poi.sl.usermodel.SlideShow;
 import org.apache.poi.sl.usermodel.SlideShowFactory;
@@ -96,9 +95,9 @@ public class TestTable {
     }
 
     @Test
-    public void directionHSLF() throws IOException {
+    public void directionHSLF() throws IOException, ReflectiveOperationException {
         assumeFalse(xslfOnly());
-        SlideShow<?,?> ppt1 = new HSLFSlideShow();
+        SlideShow<?,?> ppt1 = (SlideShow<?,?>)Class.forName("org.apache.poi.hslf.usermodel.HSLFSlideShow").newInstance();
         testTextDirection(ppt1);
         ppt1.close();
     }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestEmbedOLEPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestEmbedOLEPackage.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestEmbedOLEPackage.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestEmbedOLEPackage.java Mon
Nov 19 18:00:42 2018
@@ -17,10 +17,11 @@
 
 package org.apache.poi.ss.usermodel;
 
+import static org.apache.poi.sl.SLCommonUtils.xslfOnly;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.Assume.assumeFalse;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -48,7 +49,7 @@ public class TestEmbedOLEPackage {
     private static byte[] samplePPT, samplePPTX, samplePNG;
     
     @BeforeClass
-    public static void init() throws IOException {
+    public static void init() throws IOException, ReflectiveOperationException {
         samplePPT = getSamplePPT(false);
         samplePPTX = getSamplePPT(true);
         samplePNG = POIDataSamples.getSpreadSheetInstance().readFile("logoKarmokar4.png");
@@ -68,11 +69,7 @@ public class TestEmbedOLEPackage {
 
     @Test
     public void embedHSSF() throws IOException {
-        try {
-            Class.forName("org.apache.poi.hslf.usermodel.HSLFSlideShow");
-        } catch (Exception e) {
-            assumeTrue(false);
-        }
+        assumeFalse(xslfOnly());
 
         Workbook wb1 = new HSSFWorkbook();
         addEmbeddedObjects(wb1);
@@ -124,8 +121,9 @@ public class TestEmbedOLEPackage {
         pat2.createObjectData(anchor2, oleIdx2, picIdx);
     }
     
-    static byte[] getSamplePPT(boolean ooxml) throws IOException {
-        SlideShow<?,?> ppt = (ooxml) ? new XMLSlideShow() : new org.apache.poi.hslf.usermodel.HSLFSlideShow();
+    static byte[] getSamplePPT(boolean ooxml) throws IOException, ReflectiveOperationException
{
+        SlideShow<?,?> ppt = (ooxml) ? new XMLSlideShow()
+            : (SlideShow<?,?>)Class.forName("org.apache.poi.hslf.usermodel.HSLFSlideShow").newInstance();
         Slide<?,?> slide = ppt.createSlide();
 
         AutoShape<?,?> sh1 = slide.createAutoShape();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java Mon
Nov 19 18:00:42 2018
@@ -17,6 +17,7 @@
 package org.apache.poi.xslf.usermodel;
 
 import static org.apache.poi.sl.TestCommonSL.sameColor;
+import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -24,7 +25,6 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeFalse;
-import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr;
 
 import java.awt.Color;
 import java.io.File;
@@ -33,8 +33,8 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.usermodel.HSLFTextShape;
 import org.apache.poi.sl.usermodel.Placeholder;
+import org.apache.poi.sl.usermodel.Shape;
 import org.apache.poi.sl.usermodel.SlideShow;
 import org.apache.poi.sl.usermodel.SlideShowFactory;
 import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
@@ -950,12 +950,12 @@ public class TestXSLFTextShape {
     }
     
     @Test
-    public void metroBlob() throws IOException {
+    public void metroBlob() throws IOException, ReflectiveOperationException {
         assumeFalse(xslfOnly);
         File f = POIDataSamples.getSlideShowInstance().getFile("bug52297.ppt");
         SlideShow<?,?> ppt = SlideShowFactory.create(f);
-        HSLFTextShape sh = (HSLFTextShape)ppt.getSlides().get(1).getShapes().get(3);
-        XSLFAutoShape xsh = (XSLFAutoShape)sh.getMetroShape();
+        Shape<?, ?> sh = ppt.getSlides().get(1).getShapes().get(3);
+        XSLFAutoShape xsh = (XSLFAutoShape)sh.getClass().getMethod("getMetroShape").invoke(sh);
         String textExp = " ___ ___ ___ ________ __  _______ ___  ___________  __________
__ _____ ___ ___ ___ _______ ____ ______ ___________  _____________ ___ _______ ______  ____
______ __ ___________  __________ ___ _________  _____ ________ __________  ___ _______ __________
";
         String textAct = xsh.getText();
         ppt.close();

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
Mon Nov 19 18:00:42 2018
@@ -32,6 +32,7 @@ import org.apache.poi.hslf.usermodel.HSL
 import org.apache.poi.hsmf.MAPIMessage;
 import org.apache.poi.hsmf.datatypes.AttachmentChunks;
 import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
+import org.apache.poi.hssf.extractor.ExcelExtractor;
 import org.apache.poi.hwpf.OldWordFileFormatException;
 import org.apache.poi.hwpf.extractor.Word6Extractor;
 import org.apache.poi.hwpf.extractor.WordExtractor;
@@ -40,6 +41,8 @@ import org.apache.poi.poifs.filesystem.D
 import org.apache.poi.poifs.filesystem.Entry;
 import org.apache.poi.sl.extractor.SlideShowExtractor;
 import org.apache.poi.sl.usermodel.SlideShowFactory;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * Scratchpad-specific logic for {@link OLE2ExtractorFactory} and
@@ -50,6 +53,8 @@ import org.apache.poi.sl.usermodel.Slide
  */
 @SuppressWarnings("WeakerAccess")
 public class OLE2ScratchpadExtractorFactory {
+    private static final POILogger logger = POILogFactory.getLogger(OLE2ScratchpadExtractorFactory.class);
+
     /**
      * Look for certain entries in the stream, to figure it
      * out what format is desired
@@ -125,7 +130,16 @@ public class OLE2ScratchpadExtractorFact
             throw new IllegalStateException("The extractor didn't know which POIFS it came
from!");
         }
 
-        if (ext instanceof WordExtractor) {
+        if (ext instanceof ExcelExtractor) {
+            // These are in MBD... under the root
+            Iterator<Entry> it = root.getEntries();
+            while (it.hasNext()) {
+                Entry entry = it.next();
+                if (entry.getName().startsWith("MBD")) {
+                    dirs.add(entry);
+                }
+            }
+        } else if (ext instanceof WordExtractor) {
             // These are in ObjectPool -> _... under the root
             try {
                 DirectoryEntry op = (DirectoryEntry)
@@ -138,6 +152,7 @@ public class OLE2ScratchpadExtractorFact
                     }
                 }
             } catch(FileNotFoundException e) {
+                logger.log(POILogger.INFO, "Ignoring FileNotFoundException while extracting
Word document", e.getLocalizedMessage());
                 // ignored here
             }
             //} else if(ext instanceof PowerPointExtractor) {

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java?rev=1846931&r1=1846930&r2=1846931&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java Mon
Nov 19 18:00:42 2018
@@ -30,6 +30,12 @@ import org.apache.poi.POIDataSamples;
 import org.apache.poi.hslf.HSLFTestDataSamples;
 import org.apache.poi.hslf.usermodel.HSLFSlide;
 import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
+import org.apache.poi.sl.usermodel.Shape;
+import org.apache.poi.sl.usermodel.Slide;
+import org.apache.poi.sl.usermodel.SlideShow;
+import org.apache.poi.sl.usermodel.TextParagraph;
+import org.apache.poi.sl.usermodel.TextShape;
 import org.junit.Test;
 
 /**
@@ -228,4 +234,45 @@ public final class TestHeadersFooters
         ppt2.close();
         ppt1.close();
     }
+    @Test
+    public void bug58144a() throws IOException {
+        try (InputStream is = _slTests.openResourceAsStream("bug58144-headers-footers-2003.ppt");
+             SlideShow<?,?> ppt = new HSLFSlideShow(is)) {
+            HSLFSlide sl = (HSLFSlide) ppt.getSlides().get(0);
+            HeadersFooters hfs = sl.getHeadersFooters();
+            assertNull(hfs.getHeaderText());
+            assertEquals("Confidential", hfs.getFooterText());
+            List<List<HSLFTextParagraph>> llp = sl.getTextParagraphs();
+            assertEquals("Test", HSLFTextParagraph.getText(llp.get(0)));
+            assertFalse(llp.get(0).get(0).isHeaderOrFooter());
+        }
+    }
+
+    @Test
+    public void bug58144b() throws IOException {
+        try (InputStream is = _slTests.openResourceAsStream("bug58144-headers-footers-2007.ppt");
+             SlideShow<?,?> ppt = new HSLFSlideShow(is)) {
+            Slide<?, ?> sl = ppt.getSlides().get(0);
+            HeadersFooters hfs2 = ((HSLFSlide) sl).getHeadersFooters();
+            assertNull(hfs2.getHeaderText());
+            assertEquals("Slide footer", hfs2.getFooterText());
+
+            testSlideShow(ppt);
+        }
+    }
+
+    // copied from org.apache.poi.sl.TestHeadersFooters because of scratchpad.ignore option
+    private void testSlideShow(SlideShow<?,?> ppt) {
+        Slide<?,?> sl =  ppt.getSlides().get(0);
+
+        List<? extends Shape<?,?>> shapes = sl.getShapes();
+        TextShape<?,?> ts0 = (TextShape<?,?>)shapes.get(0);
+        assertEquals("Test file", ts0.getText());
+        TextShape<?,?> ts1 = (TextShape<?,?>)shapes.get(1);
+        assertEquals("Has some text in the headers and footers", ts1.getText());
+        TextShape<?,?> ts2 = (TextShape<?,?>)shapes.get(2);
+        assertEquals("Slide footer", ts2.getText());
+        List<? extends TextParagraph<?,?,?>> ltp = ts2.getTextParagraphs();
+        assertTrue(ltp.get(0).isHeaderOrFooter());
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message