ASF Bugzilla – Attachment 27198 Details for
Bug 51351
New Doc to FO extractor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fix ListEntryNoListTable and MBD001D0B89 tests; additional tests
patch.txt (text/plain), 6.54 KB, created by
Sergey Vladimirov
on 2011-06-23 08:11:35 UTC
(
hide
)
Description:
Patch to fix ListEntryNoListTable and MBD001D0B89 tests; additional tests
Filename:
MIME Type:
Creator:
Sergey Vladimirov
Created:
2011-06-23 08:11:35 UTC
Size:
6.54 KB
patch
obsolete
>Index: src/org/apache/poi/hwpf/extractor/AbstractToFoExtractor.java >=================================================================== >--- src/org/apache/poi/hwpf/extractor/AbstractToFoExtractor.java (revision 1138741) >+++ src/org/apache/poi/hwpf/extractor/AbstractToFoExtractor.java (working copy) >@@ -102,13 +102,6 @@ > return simplePageMaster; > } > >- protected Element addTable( Element flow ) >- { >- final Element table = document.createElementNS( NS_XSLFO, "fo:table" ); >- flow.appendChild( table ); >- return table; >- } >- > protected Element createBasicLinkExternal( String externalDestination ) > { > final Element basicLink = document.createElementNS( NS_XSLFO, >@@ -173,6 +166,11 @@ > return result; > } > >+ protected Element createTable() >+ { >+ return document.createElementNS( NS_XSLFO, "fo:table" ); >+ } >+ > protected Element createTableBody() > { > return document.createElementNS( NS_XSLFO, "fo:table-body" ); >Index: src/org/apache/poi/hwpf/extractor/WordToFoExtractor.java >=================================================================== >--- src/org/apache/poi/hwpf/extractor/WordToFoExtractor.java (revision 1138741) >+++ src/org/apache/poi/hwpf/extractor/WordToFoExtractor.java (working copy) >@@ -560,14 +560,29 @@ > > if ( currentListInfo != 0 ) > { >- final ListFormatOverride listFormatOverride = listTables >- .getOverride( paragraph.getIlfo() ); >+ if ( listTables != null ) >+ { >+ final ListFormatOverride listFormatOverride = listTables >+ .getOverride( paragraph.getIlfo() ); > >- String label = WordToFoUtils.getBulletText( listTables, >- paragraph, listFormatOverride.getLsid() ); >+ String label = WordToFoUtils.getBulletText( listTables, >+ paragraph, listFormatOverride.getLsid() ); > >- processParagraph( hwpfDocument, flow, currentTableLevel, >- paragraph, label ); >+ processParagraph( hwpfDocument, flow, currentTableLevel, >+ paragraph, label ); >+ } >+ else >+ { >+ logger.log( POILogger.WARN, >+ "Paragraph #" + paragraph.getStartOffset() + "-" >+ + paragraph.getEndOffset() >+ + " has reference to list structure #" >+ + currentListInfo >+ + ", but listTables not defined in file" ); >+ >+ processParagraph( hwpfDocument, flow, currentTableLevel, >+ paragraph, WordToFoUtils.EMPTY ); >+ } > } > else > { >@@ -581,8 +596,6 @@ > protected void processTable( HWPFDocument hwpfDocument, Element flow, > Table table, int thisTableLevel ) > { >- Element tableElement = addTable( flow ); >- > Element tableHeader = createTableHeader(); > Element tableBody = createTableBody(); > >@@ -681,6 +694,7 @@ > } > } > >+ final Element tableElement = createTable(); > if ( tableHeader.hasChildNodes() ) > { > tableElement.appendChild( tableHeader ); >@@ -688,6 +702,7 @@ > if ( tableBody.hasChildNodes() ) > { > tableElement.appendChild( tableBody ); >+ flow.appendChild( tableElement ); > } > else > { >Index: testcases/org/apache/poi/hwpf/extractor/TestWordToFoExtractorSuite.java >=================================================================== >--- testcases/org/apache/poi/hwpf/extractor/TestWordToFoExtractorSuite.java (revision 0) >+++ testcases/org/apache/poi/hwpf/extractor/TestWordToFoExtractorSuite.java (revision 0) >@@ -0,0 +1,87 @@ >+package org.apache.poi.hwpf.extractor; >+ >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FilenameFilter; >+import java.io.StringWriter; >+ >+import javax.xml.parsers.DocumentBuilderFactory; >+import javax.xml.transform.OutputKeys; >+import javax.xml.transform.Transformer; >+import javax.xml.transform.TransformerFactory; >+import javax.xml.transform.dom.DOMSource; >+import javax.xml.transform.stream.StreamResult; >+ >+import org.apache.poi.EncryptedDocumentException; >+ >+import org.apache.poi.hwpf.OldWordFileFormatException; >+ >+import junit.framework.Test; >+import junit.framework.TestCase; >+import junit.framework.TestSuite; >+import org.apache.poi.POIDataSamples; >+import org.apache.poi.hwpf.HWPFDocument; >+ >+public class TestWordToFoExtractorSuite >+{ >+ public static Test suite() >+ { >+ TestSuite suite = new TestSuite(); >+ >+ File directory = POIDataSamples.getDocumentInstance().getFile( >+ "../document" ); >+ for ( final File child : directory.listFiles( new FilenameFilter() >+ { >+ public boolean accept( File dir, String name ) >+ { >+ return name.endsWith( ".doc" ); >+ } >+ } ) ) >+ { >+ final String name = child.getName(); >+ suite.addTest( new TestCase( name ) >+ { >+ public void runTest() throws Exception >+ { >+ test( child ); >+ } >+ } ); >+ } >+ >+ return suite; >+ } >+ >+ protected static void test( File child ) throws Exception >+ { >+ HWPFDocument hwpfDocument; >+ FileInputStream fileInputStream = new FileInputStream( child ); >+ try >+ { >+ hwpfDocument = new HWPFDocument( fileInputStream ); >+ } >+ catch ( Exception exc ) >+ { >+ // unable to parse file -- not WordToFoExtractor fault >+ return; >+ } >+ finally >+ { >+ fileInputStream.close(); >+ } >+ >+ WordToFoExtractor wordToFoExtractor = new WordToFoExtractor( >+ DocumentBuilderFactory.newInstance().newDocumentBuilder() >+ .newDocument() ); >+ wordToFoExtractor.processDocument( hwpfDocument ); >+ >+ StringWriter stringWriter = new StringWriter(); >+ >+ Transformer transformer = TransformerFactory.newInstance() >+ .newTransformer(); >+ transformer.setOutputProperty( OutputKeys.INDENT, "yes" ); >+ transformer.transform( >+ new DOMSource( wordToFoExtractor.getDocument() ), >+ new StreamResult( stringWriter ) ); >+ // no exceptions >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 51351
:
27143
|
27153
|
27155
|
27177
|
27178
|
27198
|
27204
|
27205
|
27207
|
27208