Bug 50052

Summary: Add support for formating of list numbers
Product: POI Reporter: Viliam Anirud <a6537691>
Component: HWPFAssignee: POI Developers List <dev>
Status: NEEDINFO ---    
Severity: enhancement    
Priority: P2    
Version: 3.7-dev   
Target Milestone: ---   
Hardware: All   
OS: All   
Bug Depends on: 50060    
Bug Blocks:    
Attachments: Patch to support list number format (with testcase)
Added files for the patch
Patch to support list number format (with testcase)

Description Viliam Anirud 2010-10-07 03:55:51 UTC
The LVLF structure contains both PAPX and CHPX. PAPX contains additional SPRMs to be applied to paragraph, CHPX contains SPRMs for formatting the list number.

I will upload a patch that modifies the ListEntry class: in the constructor the internal _props variable will be modified: first SPRMs from ListLevel will be applied, then the SPRMs from Paragraph. Additionally, getter for NumberProperties will be added to ListLevel.
Comment 1 Viliam Anirud 2010-10-07 04:56:05 UTC
Created attachment 26133 [details]
Patch to support list number format (with testcase)

The patch contains one inconsistency, but I don't know how to handle it. See the FIXME comment in the test and in the ListEntry class.
Comment 2 Viliam Anirud 2010-10-07 04:56:26 UTC
Created attachment 26134 [details]
Added files for the patch
Comment 3 Yegor Kozlov 2010-10-07 10:14:25 UTC
The patch breaks a unit test. I'm getting the following exception if I apply the supplied code to trunk (r1005447) :


java.lang.IndexOutOfBoundsException: Index: 8, Size: 8
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at org.apache.poi.hwpf.usermodel.Range.findRange(Range.java:976)
	at org.apache.poi.hwpf.usermodel.Range.initCharacterRuns(Range.java:925)
	at org.apache.poi.hwpf.usermodel.Range.getCharacterRun(Range.java:785)
	at org.apache.poi.hwpf.usermodel.ListEntry.<init>(ListEntry.java:61)
	at org.apache.poi.hwpf.usermodel.Range.getParagraph(Range.java:831)
	at org.apache.poi.hwpf.usermodel.TestLists.testWriteRead(TestLists.java:206)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)



Yegor
Comment 4 Viliam Anirud 2010-10-08 10:05:18 UTC
I think this problem is not related to my patch. Problem is in initCharacterRuns() for paragraph 21 in the test document after writing a re-reading the document. If I remove the patch and add:
  r.getParagraph(21).numCharacterRuns();
after line 206 in TestLists.java, it will fail. 

Anyway, I will modify my patch not to rely on a single character run to be present in the paragraph. If there is none, it will take the paragraph style as a base.

I will create a new bug with a test case that fails on a version without a patch for this bug applied.
Comment 5 Viliam Anirud 2010-10-08 10:06:08 UTC
Created attachment 26139 [details]
Patch to support list number format (with testcase)
Comment 6 Nick Burch 2010-10-22 12:23:00 UTC
Thinking about your description in comment 1, isn't the inheritance order the wrong way around? If memory serves, if you apply some formatting to a paragraph, then a different value to the same property on a character run, then the one on the character run takes priority. So, shouldn't we apply all the paragraph properties first, then override them with the character ones?

For the FIXME question on properties, did you take a look in [MS-DOC].pdf to see what that had to say? If there's not an answer in there on how to identify the appropriate properties, then please drop me an email off-list, and I'll try to put you in touch with some contacts in the microsoft docs team who will hopefully be able to find the answer.
Comment 7 Viliam Anirud 2010-10-26 02:33:00 UTC
Can PAPX and CHPX really modify the same property? PAPX modifies properties of PAP while CHPX modifies properties of CHP, which are two different structures. We don't apply CHPX over PAP, we apply it over another CHP or over default values. We have default CHP for the paragraph - the stylesheet, maybe that's made you wrong. That's how I understand it so far...

For ListEntries, we have another CHPX for the list level, according to ms spec it should be used to format the list number. Applying it over anything seems incorrect in my tests: over default values is incorrect in all cases, applying over style's CHP is incorrect in some cases and applying it over first character run CHP is incorrect in some other cases.

I could not find any answer in the ms pdf, I'll write you an e-mail from my real address.