You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/09/28 13:46:22 UTC
svn commit: r1002123 - in /poi/trunk:
src/scratchpad/src/org/apache/poi/hwpf/model/types/CHPAbstractType.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
test-data/document/FloatingPictures.doc
Author: nick
Date: Tue Sep 28 11:46:22 2010
New Revision: 1002123
URL: http://svn.apache.org/viewvc?rev=1002123&view=rev
Log:
Test that shows we handle word floating and fixed pictures properly
Added:
poi/trunk/test-data/document/FloatingPictures.doc (with props)
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/CHPAbstractType.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/CHPAbstractType.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/CHPAbstractType.java?rev=1002123&r1=1002122&r2=1002123&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/CHPAbstractType.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/types/CHPAbstractType.java Tue Sep 28 11:46:22 2010
@@ -985,7 +985,7 @@ public abstract class CHPAbstractType
/**
*
- * @return the fSpec field value.
+ * @return is the fSpec field value set? (Also known as sprmCFSpec)
*/
public boolean isFSpec()
{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java?rev=1002123&r1=1002122&r2=1002123&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java Tue Sep 28 11:46:22 2010
@@ -261,4 +261,45 @@ public final class TestPictures extends
assertEquals("10a8", picture.suggestFullFileName());
assertEquals("image/unknown", picture.getMimeType());
}
+
+ /**
+ * In word you can have floating or fixed pictures.
+ * Fixed have a \u0001 in place with an offset to the
+ * picture data.
+ * Floating have a \u0008 in place, which references a
+ * \u0001 which has the offset. More than one can
+ * reference the same \u0001
+ */
+ public void testFloatingPictures() throws Exception {
+ HWPFDocument doc = HWPFTestDataSamples.openSampleFile("FloatingPictures.doc");
+ PicturesTable pictures = doc.getPicturesTable();
+
+ // There are 19 images in the picture, but some are
+ // duplicate floating ones
+ assertEquals(17, pictures.getAllPictures().size());
+
+ int plain8s = 0;
+ int escher8s = 0;
+ int image1s = 0;
+
+ Range r = doc.getRange();
+ for(int np=0; np < r.numParagraphs(); np++) {
+ Paragraph p = r.getParagraph(np);
+ for(int nc=0; nc < p.numCharacterRuns(); nc++) {
+ CharacterRun cr = p.getCharacterRun(nc);
+ if(pictures.hasPicture(cr)) {
+ image1s++;
+ } else if(pictures.hasEscherPicture(cr)) {
+ escher8s++;
+ } else if(cr.text().startsWith("\u0008")) {
+ plain8s++;
+ }
+ }
+ }
+ // Total is 20, as the 4 escher 8s all reference
+ // the same regular image
+ assertEquals(16, image1s);
+ assertEquals(4, escher8s);
+ assertEquals(0, plain8s);
+ }
}
Added: poi/trunk/test-data/document/FloatingPictures.doc
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/FloatingPictures.doc?rev=1002123&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/document/FloatingPictures.doc
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org