Docx writer: support relative image widths.

Image widths given in percent are interpreted to be relative to the text
width. This is similar to the way percent widths are handled in other
writers, e.g. HTML and LaTeX. Previously, percent widths were taken
relative to the image's native size.
This commit is contained in:
Albert Krewinkel
2022-11-21 16:32:41 +01:00
parent 4b4771f062
commit 2dec0ff52d
+4 -2
View File
@@ -1345,8 +1345,10 @@ inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do
(xpt,ypt) = desiredSizeInPoints opts attr
(either (const def) id (imageSize opts img))
-- 12700 emu = 1 pt
(xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700)
(pageWidth * 12700)
pageWidthPt = case dimension Width attr of
Just (Percent a) -> pageWidth * (floor $ a * 127)
_ -> pageWidth * 12700
(xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700) pageWidthPt
cNvPicPr = mknode "pic:cNvPicPr" [] $
mknode "a:picLocks" [("noChangeArrowheads","1")
,("noChangeAspect","1")] ()