poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r713393 - in /poi/trunk/src: documentation/content/xdocs/ scratchpad/src/org/apache/poi/hwpf/ scratchpad/testcases/org/apache/poi/hwpf/ scratchpad/testcases/org/apache/poi/hwpf/usermodel/
Date Wed, 12 Nov 2008 15:03:38 GMT
Author: nick
Date: Wed Nov 12 07:03:38 2008
New Revision: 713393

URL: http://svn.apache.org/viewvc?rev=713393&view=rev
Log:
Fix bug #46043 - correctly write out HPSF properties with HWPF

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=713393&r1=713392&r2=713393&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Wed Nov 12 07:03:38 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta4" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46043 - correctly write out HPSF
properties with HWPF</action>
            <action dev="POI-DEVELOPERS" type="add">45973 - added CreationHelper.createFormulaEvaluator(),
implemeted both for HSSF and XSSF</action>
            <action dev="POI-DEVELOPERS" type="fix">46182 - fixed Slideshow.readPictures()
to skip pictures with invalid headers</action>
            <action dev="POI-DEVELOPERS" type="fix">46137 - Handle odd files with a
ContinueRecord after EOFRecord</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=713393&r1=713392&r2=713393&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Nov 12 07:03:38 2008
@@ -34,9 +34,10 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta4" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46043 - correctly write out HPSF
properties with HWPF</action>
            <action dev="POI-DEVELOPERS" type="add">45973 - added CreationHelper.createFormulaEvaluator(),
implemeted both for HSSF and XSSF</action>
            <action dev="POI-DEVELOPERS" type="fix">46182 - fixed Slideshow.readPictures()
to skip pictures with invalid headers</action>
-     			 <action dev="POI-DEVELOPERS" type="fix">46137 - Handle odd files with a ContinueRecord
after EOFRecord</action>
+           <action dev="POI-DEVELOPERS" type="fix">46137 - Handle odd files with a
ContinueRecord after EOFRecord</action>
            <action dev="POI-DEVELOPERS" type="fix">Fixed problem with linking shared
formulas when ranges overlap</action>
            <action dev="POI-DEVELOPERS" type="fix">45784 - More fixes to SeriesTextRecord</action>
            <action dev="POI-DEVELOPERS" type="fix">46033 - fixed TableCell to correctly
set text type</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java?rev=713393&r1=713392&r2=713393&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java Wed Nov 12 07:03:38
2008
@@ -552,7 +552,8 @@
     pfs.createDocument(new ByteArrayInputStream(mainBuf), "WordDocument");
     pfs.createDocument(new ByteArrayInputStream(tableBuf), "1Table");
     pfs.createDocument(new ByteArrayInputStream(dataBuf), "Data");
-
+    writeProperties(pfs);
+    
     pfs.writeFilesystem(out);
   }
 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java?rev=713393&r1=713392&r2=713393&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java Wed Nov 12 07:03:38
2008
@@ -18,6 +18,10 @@
         
 package org.apache.poi.hwpf;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
 import junit.framework.TestCase;
 
 
@@ -30,9 +34,7 @@
   {
   }
 
-  protected void setUp()
-    throws Exception
-  {
+  protected void setUp() throws Exception {
     super.setUp();
     /**@todo verify the constructors*/
     _hWPFDocFixture = new HWPFDocFixture(this);
@@ -40,13 +42,20 @@
     _hWPFDocFixture.setUp();
   }
 
-  protected void tearDown()
-    throws Exception
-  {
-    _hWPFDocFixture.tearDown();
+  protected void tearDown() throws Exception {
+	  if(_hWPFDocFixture != null) {
+         _hWPFDocFixture.tearDown();
+	  }
 
-    _hWPFDocFixture = null;
-    super.tearDown();
+      _hWPFDocFixture = null;
+      super.tearDown();
   }
 
+  public HWPFDocument writeOutAndRead(HWPFDocument doc) throws IOException {
+	  ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	  doc.write(baos);
+	  ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+	  HWPFDocument newDoc = new HWPFDocument(bais);
+	  return newDoc;
+  }
 }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java?rev=713393&r1=713392&r2=713393&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java Wed
Nov 12 07:03:38 2008
@@ -19,10 +19,9 @@
 import java.io.File;
 import java.io.FileInputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.HWPFTestCase;
 import org.apache.poi.hwpf.model.StyleSheet;
 
 /**
@@ -30,13 +29,10 @@
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestProblems extends TestCase {
+public class TestProblems extends HWPFTestCase {
 
 	private String dirname = System.getProperty("HWPF.testdata.path");
 	
-    protected void setUp() throws Exception {
-    }
-
     /**
      * ListEntry passed no ListTable
      */
@@ -165,4 +161,14 @@
 			// Good
 		}
 	}
+	
+	public void testWriteProperties() throws Exception {
+		HWPFDocument doc = new HWPFDocument(new FileInputStream(
+    			new File(dirname, "SampleDoc.doc")));
+		assertEquals("Nick Burch", doc.getSummaryInformation().getAuthor());
+		
+		// Write and read
+		HWPFDocument doc2 = writeOutAndRead(doc);
+		assertEquals("Nick Burch", doc.getSummaryInformation().getAuthor());
+	}
 }



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


Mime
View raw message