diff options
author | Sergey Vladimirov <sergey@apache.org> | 2011-07-28 15:08:06 +0000 |
---|---|---|
committer | Sergey Vladimirov <sergey@apache.org> | 2011-07-28 15:08:06 +0000 |
commit | 984ad2c749f4889fb504e31e0b9d583b22d1bb90 (patch) | |
tree | 23a9fb092c2e4a65238cd6fd7d7d3999d44f1b22 /src/scratchpad/testcases/org/apache/poi | |
parent | dbb4386e0bc20d00b01356be4eba78ce3d4e0140 (diff) | |
download | poi-984ad2c749f4889fb504e31e0b9d583b22d1bb90.tar.gz poi-984ad2c749f4889fb504e31e0b9d583b22d1bb90.zip |
add simpliest "escher" pictures support in Word-to-HTML and Word-to-FO converters
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1151888 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases/org/apache/poi')
-rw-r--r-- | src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java index 4fd3ac216c..daa37eae87 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java @@ -29,9 +29,8 @@ import junit.framework.TestCase; import org.apache.poi.POIDataSamples; import org.apache.poi.hwpf.HWPFDocument; -import org.apache.poi.hwpf.usermodel.Picture; +import org.apache.poi.hwpf.usermodel.PictureType; import org.w3c.dom.Document; -import org.w3c.dom.Element; /** * Test cases for {@link WordToHtmlConverter} @@ -62,16 +61,21 @@ public class TestWordToHtmlConverter extends TestCase Document newDocument = DocumentBuilderFactory.newInstance() .newDocumentBuilder().newDocument(); - WordToHtmlConverter wordToHtmlConverter = !emulatePictureStorage ? new WordToHtmlConverter( - newDocument ) : new WordToHtmlConverter( newDocument ) + WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter( + newDocument ); + + if ( emulatePictureStorage ) { - @Override - protected void processImage( Element currentBlock, boolean inlined, - Picture picture ) + wordToHtmlConverter.setPicturesManager( new PicturesManager() { - processImage( currentBlock, inlined, picture, "picture.bin" ); - } - }; + public String savePicture( byte[] content, + PictureType pictureType, String suggestedName ) + { + return suggestedName; + } + } ); + } + wordToHtmlConverter.processDocument( hwpfDocument ); StringWriter stringWriter = new StringWriter(); @@ -172,20 +176,6 @@ public class TestWordToHtmlConverter extends TestCase assertContains( result, "<!--Image link to '0.emf' can be here-->" ); } - public void testPicture() throws Exception - { - String result = getHtmlText( "picture.doc", true ); - - // picture - assertContains( result, "src=\"picture.bin\"" ); - // visible size - assertContains( result, "width:3.1305554in;height:1.7250001in;" ); - // shift due to crop - assertContains( result, "left:-0.09375;top:-0.25694445;" ); - // size without crop - assertContains( result, "width:3.4125in;height:2.325in;" ); - } - public void testHyperlink() throws Exception { String result = getHtmlText( "hyperlink.doc" ); @@ -201,14 +191,6 @@ public class TestWordToHtmlConverter extends TestCase getHtmlText( "innertable.doc" ); } - public void testTableMerges() throws Exception - { - String result = getHtmlText( "table-merges.doc" ); - - assertContains( result, "<td class=\"td1\" colspan=\"3\">" ); - assertContains( result, "<td class=\"td2\" colspan=\"2\">" ); - } - public void testO_kurs_doc() throws Exception { getHtmlText( "o_kurs.doc" ); @@ -222,4 +204,33 @@ public class TestWordToHtmlConverter extends TestCase assertContains( result, "<a name=\"userref\">" ); assertContains( result, "1" ); } + + public void testPicture() throws Exception + { + String result = getHtmlText( "picture.doc", true ); + + // picture + assertContains( result, "src=\"0.emf\"" ); + // visible size + assertContains( result, "width:3.1305554in;height:1.7250001in;" ); + // shift due to crop + assertContains( result, "left:-0.09375;top:-0.25694445;" ); + // size without crop + assertContains( result, "width:3.4125in;height:2.325in;" ); + } + + public void testPicturesEscher() throws Exception + { + String result = getHtmlText( "pictures_escher.doc", true ); + assertContains( result, "<img src=\"s0.PNG\">" ); + assertContains( result, "<img src=\"s808.PNG\">" ); + } + + public void testTableMerges() throws Exception + { + String result = getHtmlText( "table-merges.doc" ); + + assertContains( result, "<td class=\"td1\" colspan=\"3\">" ); + assertContains( result, "<td class=\"td2\" colspan=\"2\">" ); + } } |