Docx writer: handle tables in table cells.
Although this is not documented in the spec, some versions of Word require a 'w:p' element inside every table cell. Thus, we add one when the contents of a cell do not already include one (e.g. when a table cell contains a table). Closes #4953.
This commit is contained in:
parent
145710c4c3
commit
b02c25b2ca
1 changed files with 7 additions and 2 deletions
|
@ -945,8 +945,13 @@ blockToOpenXML' opts (Table caption aligns widths headers rows) = do
|
||||||
else withParaProp (pCustomStyle "TableCaption")
|
else withParaProp (pCustomStyle "TableCaption")
|
||||||
$ blockToOpenXML opts (Para caption)
|
$ blockToOpenXML opts (Para caption)
|
||||||
let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()
|
let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()
|
||||||
let cellToOpenXML (al, cell) = withParaProp (alignmentFor al)
|
-- Table cells require a <w:p> element, even an empty one!
|
||||||
$ blocksToOpenXML opts cell
|
-- Not in the spec but in Word 2007, 2010. See #4953.
|
||||||
|
let cellToOpenXML (al, cell) = do
|
||||||
|
es <- withParaProp (alignmentFor al) $ blocksToOpenXML opts cell
|
||||||
|
if any (\e -> qName (elName e) == "p") es
|
||||||
|
then return es
|
||||||
|
else return $ es ++ [mknode "w:p" [] ()]
|
||||||
headers' <- mapM cellToOpenXML $ zip aligns headers
|
headers' <- mapM cellToOpenXML $ zip aligns headers
|
||||||
rows' <- mapM (mapM cellToOpenXML . zip aligns) rows
|
rows' <- mapM (mapM cellToOpenXML . zip aligns) rows
|
||||||
let borderProps = mknode "w:tcPr" []
|
let borderProps = mknode "w:tcPr" []
|
||||||
|
|
Loading…
Reference in a new issue