aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorNils Carlson <pyssling@ludd.ltu.se>2018-09-07 23:37:21 +0000
committerJohn MacFarlane <jgm@berkeley.edu>2018-09-07 16:37:21 -0700
commit12cec8f08233ea5836af77aff27771b800a35ce7 (patch)
tree15203e2ae09fcdadadd4df07e7db439faed109bb /src/Text/Pandoc
parent0178544ebed570bb6a0f91bf8fed3b87b2d22373 (diff)
downloadpandoc-12cec8f08233ea5836af77aff27771b800a35ce7.tar.gz
Fix percentage image scaling in ODT (#4881)
Image scaling in ODT was broken when a width was set to a percentage. The width was passed to the svg:width field as a pecentage, which is not correct according to the ODT standard. Instead the real dimensions should be passed as width and height and the style:rel-width attribute should be set to the percentage while style:rel-heigh attribute should be set to "scale". The converse is true if a percentage height is given. This is now fixed and documents produced are now properly scaled.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/ODT.hs4
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
index 7aecb3da5..1c9481630 100644
--- a/src/Text/Pandoc/Writers/ODT.hs
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -189,8 +189,8 @@ transformPicMath opts (Image attr@(id', cls, _) lab (src,t)) = catchError
let dims =
case (getDim Width, getDim Height) of
(Just w, Just h) -> [("width", show w), ("height", show h)]
- (Just w@(Percent p), Nothing) -> [("width", show w), ("height", show (p / ratio) ++ "%")]
- (Nothing, Just h@(Percent p)) -> [("width", show (p * ratio) ++ "%"), ("height", show h)]
+ (Just w@(Percent _), Nothing) -> [("rel-width", show w),("rel-height", "scale"),("width", show ptX ++ "pt"),("height", show ptY ++ "pt")]
+ (Nothing, Just h@(Percent _)) -> [("rel-width", "scale"),("rel-height", show h),("width", show ptX ++ "pt"),("height", show ptY ++ "pt")]
(Just w@(Inch i), Nothing) -> [("width", show w), ("height", show (i / ratio) ++ "in")]
(Nothing, Just h@(Inch i)) -> [("width", show (i * ratio) ++ "in"), ("height", show h)]
_ -> [("width", show ptX ++ "pt"), ("height", show ptY ++ "pt")]
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 21d709f98..d6ab73aa4 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -506,7 +506,9 @@ inlineToOpenDocument o ils
modify (\st -> st{ stImageId = id' + 1 })
let getDims [] = []
getDims (("width", w) :xs) = ("svg:width", w) : getDims xs
+ getDims (("rel-width", w):xs) = ("style:rel-width", w) : getDims xs
getDims (("height", h):xs) = ("svg:height", h) : getDims xs
+ getDims (("rel-height", w):xs) = ("style:rel-height", w) : getDims xs
getDims (_:xs) = getDims xs
return $ inTags False "draw:frame"
(("draw:name", "img" ++ show id') : getDims kvs) $