Handle multi stub in word#2074
Conversation
R/utils_render_xml.R
Outdated
| n_stubh_label <- length(stubh$label) | ||
| if (isTRUE(stub_available) && n_stubh_label > 0L) { | ||
| if (n_stubh_label != n_stub_cols) { | ||
| stub_labels <- c(stubh$label, rep("", n_stub_cols - 1L)) |
There was a problem hiding this comment.
Not so sure about this stuff. This happens when there is only one stub label, but multi stub columns, so using the label for the first and then empty for the others.
Should the cells merge instead ?
There was a problem hiding this comment.
For Word I think:
- if there’s one stubhead label, place it in the rightmost stub column (don’t merge cells)
- if supplied stubhead labels equals number of stubhead columns (place them right-to-left from the input order)
- lengths of stubhead labels not 1 or n stubhead columns should error
tldr: merging cells is probably difficult in Word so don’t worry about doing that.
There was a problem hiding this comment.
Actually it's not that big deal, the "span" cell here just needs a <w:gridSpan/> node in the cell properties:
<w:tcPr>
<w:tcBorders>
<w:top w:val="single" w:sz="16" w:space="0" w:color="D3D3D3"/>
<w:bottom w:val="single" w:sz="16" w:space="0" w:color="D3D3D3"/>
<w:end w:val="single" w:space="0" w:color="D3D3D3"/>
</w:tcBorders>
<w:gridSpan w:val="2"/> <!-- HERE -->
</w:tcPr>
I guess we can easily adjust that we had "one" instead of c("one", "two", "three") for stubh$label
There was a problem hiding this comment.
I did eventually go in that direction, with tests to back it up. cc @shannonhaughton @thebioengineer
So for example the "one" stub label cell in this table (last test in test_that("multicolumn stub are supported")
is made of these two tc with these tcPr:
<w:tcPr>
<w:tcBorders>
<w:top w:val="single" w:sz="16" w:space="0" w:color="D3D3D3"/>
<w:start w:val="single" w:space="0" w:color="D3D3D3"/>
<w:end w:val="single" w:space="0" w:color="D3D3D3"/>
</w:tcBorders>
<w:vMerge w:val="restart"/>
<w:vAlign w:val="bottom"/>
<w:gridSpan w:val="3"/>
</w:tcPr>and
<w:tcPr>
<w:tcBorders>
<w:bottom w:val="single" w:sz="16" w:space="0" w:color="D3D3D3"/>
<w:start w:val="single" w:space="0" w:color="D3D3D3"/>
<w:end w:val="single" w:space="0" w:color="D3D3D3"/>
</w:tcBorders>
<w:vMerge w:val="continue"/>
<w:gridSpan w:val="3"/>
</w:tcPr>|
This is great! I'll fix that small test failure in a separate commit and merge this. |
Summary
This is bare minimum (wip) support for multi column stub for word.
This will need some more testing inspired by the
test-multicolumn_stub.Rfile, as well as probably handling of the vertical cell merging in the stub. But that's a start ...Marking as draft until we can address those.
Related GitHub Issues and PRs
Checklist
testthatunit tests totests/testthatfor any new functionality.