poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1719758 - in /poi: site/src/documentation/content/xdocs/ trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/ trunk/src/scratchpad/src/org/apache/poi/hslf/record/ trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/ ...
Date Sun, 13 Dec 2015 01:50:24 GMT
Author: kiwiwings
Date: Sun Dec 13 01:50:24 2015
New Revision: 1719758

URL: http://svn.apache.org/viewvc?rev=1719758&view=rev
Log:
#58718 - Master styles not initialized when running multithreaded

Added:
    poi/trunk/test-data/slideshow/bug58718_008495.ppt   (with props)
    poi/trunk/test-data/slideshow/bug58718_008524.ppt   (with props)
    poi/trunk/test-data/slideshow/bug58718_008558.ppt   (with props)
    poi/trunk/test-data/slideshow/bug58718_349008.ppt   (with props)
Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TabStopPropCollection.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1719758&r1=1719757&r2=1719758&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Sun Dec 13 01:50:24 2015
@@ -39,9 +39,9 @@
         <person id="YK" name="Yegor Kozlov" email="yegor@apache.org" />
     </devs>
 
-    <!-- <release version="3.14-beta2" date="2016-??-??">
-
-    </release> -->
+    <release version="3.14-beta2" date="2016-??-??">
+        <action dev="PD" type="add" fixes-bug="58718">Master styles not initialized
when running multithreaded</action>
+    </release>
 
     <release version="3.14-beta1" date="2015-12-14">
         <action dev="PD" type="add" fixes-bug="58084">Corrupted .xlsx file created
when styles with borders are cloned from other workbooks</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TabStopPropCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TabStopPropCollection.java?rev=1719758&r1=1719757&r2=1719758&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TabStopPropCollection.java
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TabStopPropCollection.java
Sun Dec 13 01:50:24 2015
@@ -93,13 +93,13 @@ public class TabStopPropCollection exten
      */
     public void parseProperty(byte data[], int offset) {
         int count = LittleEndian.getUShort(data, offset);
-        offset += LittleEndianConsts.SHORT_SIZE;
+        int off = offset + LittleEndianConsts.SHORT_SIZE;
         for (int i=0; i<count; i++) {
-            int position = LittleEndian.getShort(data, offset);
-            offset += LittleEndianConsts.SHORT_SIZE;
-            int recVal = LittleEndian.getShort(data, offset);
+            int position = LittleEndian.getShort(data, off);
+            off += LittleEndianConsts.SHORT_SIZE;
+            int recVal = LittleEndian.getShort(data, off);
             TabStopType type = TabStopType.fromRecordVal(recVal);
-            offset += LittleEndianConsts.SHORT_SIZE;
+            off += LittleEndianConsts.SHORT_SIZE;
             tabStops.add(new TabStop(position, type));
             
         }
@@ -109,4 +109,15 @@ public class TabStopPropCollection exten
     public int getSize() {
         return LittleEndianConsts.SHORT_SIZE + tabStops.size()*LittleEndianConsts.INT_SIZE;
     }
+    
+    @Override
+    public TabStopPropCollection clone() {
+        TabStopPropCollection other = (TabStopPropCollection)super.clone();
+        other.tabStops = new ArrayList<TabStop>();
+        for (TabStop ts : tabStops) {
+            TabStop tso = new TabStop(ts.getPosition(), ts.getType());
+            other.tabStops.add(tso);
+        }
+        return other;
+    }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java?rev=1719758&r1=1719757&r2=1719758&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java Sun
Dec 13 01:50:24 2015
@@ -98,6 +98,7 @@ public class TextProp implements Cloneab
 		}
 	}
 	
+	@Override
 	public int hashCode() {
         final int prime = 31;
         int result = 1;
@@ -108,6 +109,7 @@ public class TextProp implements Cloneab
         return result;
     }
 
+	@Override
     public boolean equals(Object obj) {
         if (this == obj) return true;
         if (obj == null) return false;
@@ -121,4 +123,15 @@ public class TextProp implements Cloneab
         if (sizeOfDataBlock != other.sizeOfDataBlock) return false;
         return true;
     }
+    
+    @Override
+    public String toString() {
+        int len;
+        switch (sizeOfDataBlock) {
+        case 1: len = 4; break;
+        case 2: len = 6; break;
+        default: len = 10; break;
+        }
+        return String.format("%s = %d (%0#"+len+"X mask / %d bytes)", propName, dataValue,
maskInHeader, sizeOfDataBlock);
+    }
 }
\ No newline at end of file

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java?rev=1719758&r1=1719757&r2=1719758&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
Sun Dec 13 01:50:24 2015
@@ -214,13 +214,11 @@ public class TextPropCollection {
 				// Bingo, data contains this property
 				TextProp prop = tp.clone();
 				int val = 0;
-				if (prop instanceof TabStopPropCollection) {
-				    ((TabStopPropCollection)prop).parseProperty(data, dataOffset+bytesPassed);
-				} else if (prop.getSize() == 2) {
+				if (prop.getSize() == 2) {
 					val = LittleEndian.getShort(data,dataOffset+bytesPassed);
 				} else if(prop.getSize() == 4) {
 					val = LittleEndian.getInt(data,dataOffset+bytesPassed);
-				} else if (prop.getSize() == 0) {
+				} else if (prop.getSize() == 0 && !(prop instanceof TabStopPropCollection)) {
                     //remember "special" bits.
                     maskSpecial |= tp.getMask();
                     continue;
@@ -228,6 +226,8 @@ public class TextPropCollection {
 				
 				if (prop instanceof BitMaskTextProp) {
 				    ((BitMaskTextProp)prop).setValueWithMask(val, containsField);
+				} else if (prop instanceof TabStopPropCollection) {
+				    ((TabStopPropCollection)prop).parseProperty(data, dataOffset+bytesPassed);
 				} else {
 				    prop.setValue(val);
 				}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java?rev=1719758&r1=1719757&r2=1719758&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java Sun Dec
13 01:50:24 2015
@@ -144,7 +144,7 @@ public final class TxMasterStyleAtom ext
         charStyles = new ArrayList<TextPropCollection>(levels);
 
         for(short i = 0; i < levels; i++) {
-            TextPropCollection prprops = new TextPropCollection(0, TextPropType.paragraph);
//  getParagraphProps(type, j)
+            TextPropCollection prprops = new TextPropCollection(0, TextPropType.paragraph);
             if (type >= TextHeaderAtom.CENTRE_BODY_TYPE) {
                 // Fetch the 2 byte value, that is safe to ignore for some types of text
                 short indentLevel = LittleEndian.getShort(_data, pos);
@@ -162,7 +162,7 @@ public final class TxMasterStyleAtom ext
 
             head = LittleEndian.getInt(_data, pos);
             pos += LittleEndian.INT_SIZE;
-            TextPropCollection chprops = new TextPropCollection(0, TextPropType.character);
//  getCharacterProps(type, j)
+            TextPropCollection chprops = new TextPropCollection(0, TextPropType.character);
             pos += chprops.buildTextPropList( head, _data, pos);
             charStyles.add(chprops);
         }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=1719758&r1=1719757&r2=1719758&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Sun Dec
13 01:50:24 2015
@@ -39,6 +39,7 @@ import org.apache.poi.ddf.EscherColorRef
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.hslf.HSLFTestDataSamples;
 import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
+import org.apache.poi.hslf.extractor.PowerPointExtractor;
 import org.apache.poi.hslf.model.HeadersFooters;
 import org.apache.poi.hslf.record.Document;
 import org.apache.poi.hslf.record.Record;
@@ -756,6 +757,17 @@ public final class TestBugs {
         assertEquals("foobaa", tr.getRawText());
         ppt2.close();
     }
+
+    @Test
+    public void bug58718() throws IOException {
+        String files[] = { "bug58718_008524.ppt","bug58718_008558.ppt","bug58718_349008.ppt","bug58718_008495.ppt",
 }; 
+        for (String f : files) {
+            File sample = HSLFTestDataSamples.getSampleFile(f);
+            PowerPointExtractor ex = new PowerPointExtractor(sample.getAbsolutePath());
+            assertNotNull(ex.getText());
+            ex.close();
+        }
+    }
     
     private static HSLFSlideShow open(String fileName) throws IOException {
         File sample = HSLFTestDataSamples.getSampleFile(fileName);

Added: poi/trunk/test-data/slideshow/bug58718_008495.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/bug58718_008495.ppt?rev=1719758&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/slideshow/bug58718_008495.ppt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: poi/trunk/test-data/slideshow/bug58718_008524.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/bug58718_008524.ppt?rev=1719758&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/slideshow/bug58718_008524.ppt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: poi/trunk/test-data/slideshow/bug58718_008558.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/bug58718_008558.ppt?rev=1719758&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/slideshow/bug58718_008558.ppt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: poi/trunk/test-data/slideshow/bug58718_349008.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/bug58718_349008.ppt?rev=1719758&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/slideshow/bug58718_349008.ppt
------------------------------------------------------------------------------
    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


Mime
View raw message