PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.16k stars 2.68k forks source link

Table Borders Fixes #2535

Open oleibman opened 6 months ago

oleibman commented 6 months ago

Fix #2402. Fix #2474. Both issues deal with borders around tables when they aren't wanted. There are 3 big issues in the code, and several minor ones.

First big issue - Word table styles can have both a styleId and a name, which are often different from each other, and each of which is used by various Word functions, and what documentation I can find is far from clear on the difference. I have added a tableStyle property (for styleId) to Style/Table, and the reader will now preserve both styleId and name. It will similarly preserve basedOn, which in now a private property in Style/Paragraph, but is changed to be a protected property in Style.

Second big issue - Word2007 Reader assumes that table style can be specified either by name or by inline declarations, but not both. Guess what? It is now changed to support both. This makes the delta for Reader/Word2007/AbstractPart appear to be much more complicated than it actually is. The change is almost entirely of the form:

if (condition) {short_code_block} else {long_code_block}

to

long_code_block

Third big issue. In html, td does not inherit border styles from table. In word, cell border styles are specified in table styles (as insideH/V), so they do, in effect, inherit. This is resolved, as best as I can, by having each td/th without its own style use the table border style. So adding an html border style should produce a consistent result in Html and Docx output.

Minor issues:

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

Checklist:

coveralls commented 6 months ago

Coverage Status

coverage: 97.219% (+0.01%) from 97.208% when pulling 7c4eb2102fa4a928e62a4b5d8f9a6adaead79360 on oleibman:styleid into 2daa50c6f34c9cb6c532f72350e4bd8d466d6c71 on PHPOffice:master.

Progi1984 commented 5 months ago

@oleibman You have conflicting files. Could you rebase your PR ?

oleibman commented 5 months ago

@Progi1984 I don't know how to rebase the PR. I do know how to resolve the trivial conflicts here on Github, but you didn't like the way it handled that with an earlier PR - I think it did a "merge commit" rather than your preferred rebase. Why wasn't that okay? And, assuming it still wouldn't be okay here, how do I go about rebasing?