Bug 49919 - Implement support for BorderCode
Summary: Implement support for BorderCode
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-09-13 06:00 UTC by Viliam Anirud
Modified: 2010-10-07 09:58 UTC (History)
0 users

Patch to support borders (5.17 KB, patch)
2010-09-16 07:52 UTC, Viliam Anirud
Details | Diff
Patch to support borders (with testcase) (5.61 KB, patch)
2010-10-07 01:45 UTC, Viliam Anirud
Details | Diff
Added files for the patch (8.38 KB, application/octet-stream)
2010-10-07 01:45 UTC, Viliam Anirud

Note You need to log in before you can comment on or make changes to this bug.
Description Viliam Anirud 2010-09-13 06:00:51 UTC
I'd like to finish implementation and create a patch for BorderCodes. Currently it reads only the Word 97 structure (4-byte), and the class does not provide any getters or setters. Word 2000 and above use new 8-byte version, which is changed in new SPRM, which are currently not processed.

I don't know how to do it best in regard of backward compatibility. Two BorderCode structures should be supported. They have the same properties, except for color, which is changed from 8-bit to 24-bit in word 2000.

I suggest this:
1. rename existing BorderCode to BorderCode97 and create new BorderCode2000. These will read/write values as appropriate for particular version.
2. create new class BorderCode, which will delegete to BorderCode97 or BorderCode2000. Will provide method returning boolean as whether 8 or 24-bit color is valid. It will not contain following public methods from current implementation: 
  - the public contructor
  - the toInt method
As such it will not be full backwards compatible, but I think this is not the issue, as currently the class is useless.

Note, that there are different BorderCode structures for Word 95 and Word 1.0, but as I understand, we do not support these.

Please let me know.
Comment 1 Viliam Anirud 2010-09-16 07:52:03 UTC
Created attachment 26032 [details]
Patch to support borders

Attached is the patch created by following the instructions in the Contribution Guidelines. How it is implemented:

- no support for Word 2000 structure of BorderCode. The only difference is that Word 2000 has 24-bit color while Word 97 version has only 16 colors. In my tests Word 2003 and 2007 saves both structures, so you are able to read it anyway.

- get methods for borders were added to TableRow: for some strange reason TableRow extends Paragraph. Paragraph has getXxxBorder methods, but they return incorrect values, because they read from _props superclas's field instead of _tprops field

Please give feedback or merge.
Comment 2 Nick Burch 2010-09-16 09:52:31 UTC
To answer the question - the TableXXXX classes extend from paragraph because in the file format they're really just paragraphs with special properties!

In terms of table vs paragraph properties: For a table where the row has a border, and a paragraph in it has one, do we need to merge the two properties?
Comment 3 Nick Burch 2010-09-16 12:04:47 UTC
The patch looks good, thanks for that

Any chance of a quick unit test for it? I guess we'll need a word file with a table in it, some rows with borders and some without. The test would then check each row in turn, and ensure that the borders show up / don't show up as expected. I'm happy to commit this to svn once we have a test to go with it
Comment 4 Viliam Anirud 2010-10-07 01:45:18 UTC
Created attachment 26128 [details]
Patch to support borders (with testcase)

Updated patch with a testcase.
Comment 5 Viliam Anirud 2010-10-07 01:45:47 UTC
Created attachment 26129 [details]
Added files for the patch
Comment 6 Yegor Kozlov 2010-10-07 09:58:13 UTC
Applied in r1005447