fixed [Bug 42677] - HSLF SlideShow write() issues on tables

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@550731 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2007-06-26 08:09:24 +00:00
parent ada61241db
commit f6e06619e7
2 changed files with 31 additions and 2 deletions

View File

@ -160,11 +160,15 @@ public class TextPropCollection {
StyleTextPropAtom.writeLittleEndian(reservedField,o);
}
// The the mask field
// Then the mask field
int mask = 0;
for(int i=0; i<textPropList.size(); i++) {
TextProp textProp = (TextProp)textPropList.get(i);
mask += textProp.getWriteMask();
//sometimes header indicates that the bitmask is present but its value is 0
if (textProp instanceof BitMaskTextProp)
mask |= (textProp.getWriteMask() == 0 ? 1 : textProp.getWriteMask());
else
mask |= textProp.getWriteMask();
}
StyleTextPropAtom.writeLittleEndian(mask,o);

View File

@ -26,6 +26,7 @@ import org.apache.poi.hslf.model.textproperties.TextProp;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.record.StyleTextPropAtom.*;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.util.HexDump;
import junit.framework.TestCase;
import java.io.ByteArrayOutputStream;
@ -734,4 +735,28 @@ public class TestStyleTextPropAtom extends TestCase {
assertEquals(0, chprops.findByName("asian_or_complex").getValue());
assertEquals(1, chprops.findByName("char_unknown_2").getValue());
}
/**
* Check the test data for Bug 42677.
*/
public void test42677() throws Exception {
int length = 18;
byte[] data = {0x00, 0x00, (byte)0xA1, 0x0F, 0x28, 0x00, 0x00, 0x00,
0x13, 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , (byte)0xF1 , 0x20 , 0x00, 0x00 , 0x00 , 0x00 ,
0x22 , 0x20 , 0x00 , 0x00 , 0x64 , 0x00 , 0x00 , 0x00 , 0x00 , (byte)0xFF ,
0x00 , 0x00 , 0x13 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x63 , 0x00 ,
0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x0F , 0x00
};
StyleTextPropAtom stpa = new StyleTextPropAtom(data,0,data.length);
stpa.setParentTextSize(length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
stpa.writeOut(baos);
byte[] b = baos.toByteArray();
assertEquals(data.length, b.length);
for(int i=0; i<data.length; i++) {
assertEquals(data[i],b[i]);
}
}
}