@@ -58,6 +58,7 @@ import Control.Monad.State
58import Data.List (intercalate)
58import Data.List (intercalate)
59import Data.Default
59import Data.Default
60import Text.Pandoc.Definition
60import Text.Pandoc.Definition
61+import Text.Pandoc.ImageSize
61import Text.Pandoc.Slides (getSlideLevel)
62import Text.Pandoc.Slides (getSlideLevel)
62import Text.Pandoc.Options
63import Text.Pandoc.Options
63import Text.Pandoc.Logging
64import Text.Pandoc.Logging
@@ -138,7 +139,7 @@ data Slide = MetadataSlide { metadataSlideTitle :: [ParaElem]
139 deriving (Show, Eq)
140 deriving (Show, Eq)
141−data Shape = Pic PicProps FilePath Text.Pandoc.Definition.Attr [ParaElem]
142+data Shape = Pic PicProps FilePath [ParaElem]
142 | GraphicFrame [Graphic] [ParaElem]
143 | GraphicFrame [Graphic] [ParaElem]
143 | TextBox [Paragraph]
144 | TextBox [Paragraph]
144 deriving (Show, Eq)
145 deriving (Show, Eq)
@@ -230,10 +231,14 @@ instance Default RunProps where
232data PicProps = PicProps { picPropLink :: Maybe LinkTarget
233data PicProps = PicProps { picPropLink :: Maybe LinkTarget
234+ , picWidth :: Maybe Dimension
235+ , picHeight :: Maybe Dimension
233 } deriving (Show, Eq)
236 } deriving (Show, Eq)
235instance Default PicProps where
238instance Default PicProps where
236 def = PicProps { picPropLink = Nothing
239 def = PicProps { picPropLink = Nothing
240+ , picWidth = Nothing
241+ , picHeight = Nothing
239--------------------------------------------------
244--------------------------------------------------
@@ -407,17 +412,28 @@ rowToParagraphs algns tblCells = do
407 let pairs = zip (algns ++ repeat AlignDefault) tblCells
412 let pairs = zip (algns ++ repeat AlignDefault) tblCells
408 mapM (\(a, tc) -> cellToParagraphs a tc) pairs
413 mapM (\(a, tc) -> cellToParagraphs a tc) pairs
415+withAttr :: Attr -> Shape -> Shape
416+withAttr attr (Pic picPr url caption) =
417+ let picPr' = picPr { picWidth = dimension Width attr
418+ , picHeight = dimension Height attr
421+ Pic picPr' url caption
410blockToShape :: Block -> Pres Shape
424blockToShape :: Block -> Pres Shape
411blockToShape (Plain (il:_)) | Image attr ils (url, _) <- il =
425blockToShape (Plain (il:_)) | Image attr ils (url, _) <- il =
412− Pic def url attr <$> (inlinesToParElems ils)
426+ (withAttr attr . Pic def url) <$> (inlinesToParElems ils)
413blockToShape (Para (il:_)) | Image attr ils (url, _) <- il =
427blockToShape (Para (il:_)) | Image attr ils (url, _) <- il =
414− Pic def url attr <$> (inlinesToParElems ils)
428+ (withAttr attr . Pic def url) <$> (inlinesToParElems ils)
415blockToShape (Plain (il:_)) | Link _ (il':_) target <- il
429blockToShape (Plain (il:_)) | Link _ (il':_) target <- il
416 , Image attr ils (url, _) <- il' =
430 , Image attr ils (url, _) <- il' =
417− Pic def{picPropLink = Just $ ExternalTarget target} url attr <$> (inlinesToParElems ils)
431+ (withAttr attr . Pic def {picPropLink = Just $ ExternalTarget target} url) <$>
432+ (inlinesToParElems ils)
418blockToShape (Para (il:_)) | Link _ (il':_) target <- il
433blockToShape (Para (il:_)) | Link _ (il':_) target <- il
419 , Image attr ils (url, _) <- il' =
434 , Image attr ils (url, _) <- il' =
420− Pic def{picPropLink = Just $ ExternalTarget target} url attr <$> (inlinesToParElems ils)
435+ (withAttr attr . Pic def{picPropLink = Just $ ExternalTarget target} url) <$>
436+ (inlinesToParElems ils)
421blockToShape (Table caption algn _ hdrCells rows) = do
437blockToShape (Table caption algn _ hdrCells rows) = do
422 caption' <- inlinesToParElems caption
438 caption' <- inlinesToParElems caption
423 hdrCells' <- rowToParagraphs algn hdrCells
439 hdrCells' <- rowToParagraphs algn hdrCells
@@ -438,7 +454,7 @@ blockToShape blk = do paras <- blockToParagraphs blk
438combineShapes :: [Shape] -> [Shape]
454combineShapes :: [Shape] -> [Shape]
439combineShapes [] = []
455combineShapes [] = []
440combineShapes (s : []) = [s]
456combineShapes (s : []) = [s]
441−combineShapes (pic@(Pic _ _ _ _) : ss) = pic : combineShapes ss
457+combineShapes (pic@(Pic _ _ _) : ss) = pic : combineShapes ss
442combineShapes ((TextBox []) : ss) = combineShapes ss
458combineShapes ((TextBox []) : ss) = combineShapes ss
443combineShapes (s : TextBox [] : ss) = combineShapes (s : ss)
459combineShapes (s : TextBox [] : ss) = combineShapes (s : ss)
444combineShapes ((TextBox (p:ps)) : (TextBox (p':ps')) : ss) =
460combineShapes ((TextBox (p:ps)) : (TextBox (p':ps')) : ss) =
@@ -650,9 +666,9 @@ applyToParagraph f para = do
650 return $ para {paraElems = paraElems'}
666 return $ para {paraElems = paraElems'}
652applyToShape :: Monad m => (ParaElem -> m ParaElem) -> Shape -> m Shape
668applyToShape :: Monad m => (ParaElem -> m ParaElem) -> Shape -> m Shape
653−applyToShape f (Pic pPr fp attr pes) = do
669+applyToShape f (Pic pPr fp pes) = do
654 pes' <- mapM f pes
670 pes' <- mapM f pes
655− return $ Pic pPr fp attr pes'
671+ return $ Pic pPr fp pes'
656applyToShape f (GraphicFrame gfx pes) = do
672applyToShape f (GraphicFrame gfx pes) = do
657 pes' <- mapM f pes
673 pes' <- mapM f pes
658 return $ GraphicFrame gfx pes'
674 return $ GraphicFrame gfx pes'