org.apache.poi.xslf.extractor.XSLFPowerPointExtractor Java Examples
The following examples show how to use
org.apache.poi.xslf.extractor.XSLFPowerPointExtractor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OOXMLPowerpointFormatModule.java From ontopia with Apache License 2.0 | 5 votes |
@Override public void readContent(ClassifiableContentIF cc, TextHandlerIF handler) { try { OPCPackage opc = OPCPackage.open(new ByteArrayInputStream(cc.getContent())); XSLFPowerPointExtractor extractor = new XSLFPowerPointExtractor(opc); String s = extractor.getText(); char[] c = s.toCharArray(); handler.startRegion("document"); handler.text(c, 0, c.length); handler.endRegion(); } catch (Exception e) { throw new OntopiaRuntimeException(e); } }
Example #2
Source File: MSPowerpointIndexerTest.java From carbon-apimgt with Apache License 2.0 | 4 votes |
@Test public void testShouldReturnIndexedDocumentWhenParameterCorrect() throws Exception { POIFSFileSystem ppExtractor = Mockito.mock(POIFSFileSystem.class); PowerPointExtractor powerPointExtractor = Mockito.mock(PowerPointExtractor.class); XSLFPowerPointExtractor xslfExtractor = Mockito.mock(XSLFPowerPointExtractor.class); XMLSlideShow xmlSlideShow = Mockito.mock(XMLSlideShow.class); PowerMockito.whenNew(POIFSFileSystem.class).withParameterTypes(InputStream.class) .withArguments(Mockito.any(InputStream.class)) .thenThrow(OfficeXmlFileException.class) .thenReturn(ppExtractor) .thenThrow(APIManagementException.class); PowerMockito.whenNew(PowerPointExtractor.class).withParameterTypes(POIFSFileSystem.class) .withArguments(ppExtractor).thenReturn(powerPointExtractor); PowerMockito.whenNew(XMLSlideShow.class).withParameterTypes(InputStream.class) .withArguments(Mockito.any()) .thenReturn(xmlSlideShow); PowerMockito.whenNew(XSLFPowerPointExtractor.class).withArguments(xmlSlideShow).thenReturn(xslfExtractor); Mockito.when(powerPointExtractor.getText()).thenReturn(""); Mockito.when(xslfExtractor.getText()).thenReturn(""); MSPowerpointIndexer indexer = new MSPowerpointIndexer(); IndexDocument ppDoc = indexer.getIndexedDocument(file2Index); // should return the default media type when media type is not defined in file2Index if (!"application/vnd.ms-powerpoint".equals(ppDoc.getFields().get(IndexingConstants.FIELD_MEDIA_TYPE).get(0))) { Assert.fail(); } // should return the media type we have set in the file2Index file2Index.mediaType = "text/html"; ppDoc = indexer.getIndexedDocument(file2Index); if (!"text/html".equals(ppDoc.getFields().get(IndexingConstants.FIELD_MEDIA_TYPE).get(0))) { Assert.fail(); } // should return the media type we have set in the file2Index even if exception occurred while reading the file ppDoc = indexer.getIndexedDocument(file2Index); if (!"text/html".equals(ppDoc.getFields().get(IndexingConstants.FIELD_MEDIA_TYPE).get(0))) { Assert.fail(); } }