ASF Bugzilla – Attachment 19398 Details for
Bug 40143
HSLF: RichTextRun returns wrong style attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
the patch which fixed the order of properties in StyleTextPropAtom
props_order.patch (text/plain), 6.25 KB, created by
Yegor Kozlov
on 2007-01-12 01:24:22 UTC
(
hide
)
Description:
the patch which fixed the order of properties in StyleTextPropAtom
Filename:
MIME Type:
Creator:
Yegor Kozlov
Created:
2007-01-12 01:24:22 UTC
Size:
6.25 KB
patch
obsolete
>Index: src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java >=================================================================== >--- src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (revision 495514) >+++ src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (working copy) >@@ -25,6 +25,8 @@ > import java.io.ByteArrayOutputStream; > import java.util.LinkedList; > import java.util.Vector; >+import java.util.List; >+import java.util.Iterator; > > /** > * A StyleTextPropAtom (type 4001). Holds basic character properties >@@ -90,33 +92,33 @@ > "bullet", "bullet.hardfont", > "bullet.hardcolor", "bullet.hardsize"} > ), >+ new TextProp(2, 0x80, "bullet.char"), > new TextProp(2, 0x10, "bullet.font"), > new TextProp(4, 0x20, "bullet.color"), > new TextProp(2, 0x40, "bullet.size"), >- new TextProp(2, 0x80, "bullet.char"), >- new TextProp(2, 0x100, "text.offset"), >+ new AlignmentTextProp(), >+ new TextProp(2, 0x400, "bullet.offset"), > new TextProp(2, 0x200, "para_unknown_2"), >- new TextProp(2, 0x400, "bullet.offset"), >- new AlignmentTextProp(), // 0x800 >+ new TextProp(2, 0x100, "text.offset"), > new TextProp(2, 0x1000, "linespacing"), > new TextProp(2, 0x2000, "spacebefore"), > new TextProp(2, 0x4000, "spaceafter"), > new TextProp(2, 0x8000, "para_unknown_4"), > new TextProp(2, 0x10000, "para_unknown_5"), >- new TextProp(2, 0xA0000, "para_unknown_6"), >+ new TextProp(2, 0xE0000, "para_unknown_6"), > new TextProp(2, 0x200000, "para_unknown_7") > }; > /** All the different kinds of character properties we might handle */ > public static TextProp[] characterTextPropTypes = new TextProp[] { > new CharFlagsTextProp(), > new TextProp(2, 0x10000, "font.index"), >+ new TextProp(2, 0x200000, "asian_or_complex"), >+ new TextProp(2, 0x400000, "char_unknown_2"), >+ new TextProp(2, 0x800000, "symbol"), > new TextProp(2, 0x20000, "font.size"), > new TextProp(4, 0x40000, "font.color"), > new TextProp(2, 0x80000, "offset"), > new TextProp(2, 0x100000, "char_unknown_1"), >- new TextProp(2, 0x200000, "asian_or_complex"), >- new TextProp(2, 0x400000, "char_unknown_2"), >- new TextProp(2, 0x800000, "symbol"), > new TextProp(2, 0x1000000, "char_unknown_3"), > new TextProp(2, 0x2000000, "char_unknown_4"), > new TextProp(2, 0x4000000, "char_unknown_5"), >@@ -127,7 +129,6 @@ > new TextProp(2, 0x80000000, "char_unknown_10"), > }; > >- > /* *************** record code follows ********************** */ > > /** >@@ -730,4 +731,34 @@ > ); > } > } >+ >+ /** >+ * Dump the record content into <code>StringBuffer</code> >+ * >+ * @return the string representation of the record data >+ */ >+ public String toString(){ >+ StringBuffer out = new StringBuffer(); >+ out.append("Paragraph properties\n"); >+ for (Iterator it1 = getParagraphStyles().iterator(); it1.hasNext();) { >+ TextPropCollection pr = (TextPropCollection)it1.next(); >+ out.append(" chars covered: " + pr.getCharactersCovered() + "\n"); >+ for (Iterator it2 = pr.getTextPropList().iterator(); it2.hasNext(); ) { >+ TextProp p = (TextProp)it2.next(); >+ out.append(" " + p.getName() + " = " + p.getValue() + "\n"); >+ } >+ } >+ >+ out.append("Character properties\n"); >+ for (Iterator it1 = getCharacterStyles().iterator(); it1.hasNext();) { >+ TextPropCollection pr = (TextPropCollection)it1.next(); >+ out.append(" chars covered: " + pr.getCharactersCovered() + "\n"); >+ for (Iterator it2 = pr.getTextPropList().iterator(); it2.hasNext(); ) { >+ TextProp p = (TextProp)it2.next(); >+ out.append(" " + p.getName() + " = " + p.getValue() + "\n"); >+ } >+ } >+ >+ return out.toString(); >+ } > } >Index: src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java >=================================================================== >--- src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java (revision 495514) >+++ src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java (working copy) >@@ -127,7 +127,17 @@ > }; > private int data_c_text_len = 123-1; > >- >+ /** >+ * From a real file supplied for Bug 40143 by tales@great.ufc.br >+ */ >+ private byte[] data_d = { >+ 0x00, 0x00, 0xA1-256, 0x0F, 0x1E, 0x00, 0x00, 0x00, //header >+ (byte)0xA0, 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 , >+ 0x01 , 0x00, (byte)0xA0 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x63 , 0x00 , >+ 0x01 , 0x00, 0x01 , 0x00 , 0x00, 0x00 , 0x01 , 0x00 , 0x14 , 0x00 >+ }; >+ private int data_d_text_len = 0xA0-1; >+ > public void testRecordType() throws Exception { > StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length); > StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); >@@ -699,4 +709,26 @@ > > // If we get here, we didn't break > } >+ >+ /** >+ * Check the test data for Bug 40143. >+ */ >+ public void testBug40143() throws Exception { >+ StyleTextPropAtom atom = new StyleTextPropAtom(data_d, 0, data_d.length); >+ atom.setParentTextSize(data_d_text_len); >+ >+ TextPropCollection prprops = (TextPropCollection)atom.getParagraphStyles().getFirst(); >+ assertEquals(data_d_text_len+1, prprops.getCharactersCovered()); >+ assertEquals(1, prprops.getTextPropList().size()); //1 property found >+ assertEquals(1, prprops.findByName("alignment").getValue()); >+ >+ TextPropCollection chprops = (TextPropCollection)atom.getCharacterStyles().getFirst(); >+ assertEquals(data_d_text_len+1, chprops.getCharactersCovered()); >+ assertEquals(5, chprops.getTextPropList().size()); //5 properties found >+ assertEquals(1, chprops.findByName("char_flags").getValue()); >+ assertEquals(1, chprops.findByName("font.index").getValue()); >+ assertEquals(20, chprops.findByName("font.size").getValue()); >+ assertEquals(0, chprops.findByName("asian_or_complex").getValue()); >+ assertEquals(1, chprops.findByName("char_unknown_2").getValue()); >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 40143
:
18664
|
19385
|
19393
| 19398