@@ -213,26 +213,6 @@ type Pixels = Integer
213data Presentation = Presentation [Slide]
213data Presentation = Presentation [Slide]
214 deriving (Show)
214 deriving (Show)
216−-- data PresentationSize = PresentationSize { presSizeWidth :: Pixels
217−-- , presSizeRatio :: PresentationRatio
219−-- deriving (Show, Eq)
221−-- data PresentationRatio = Ratio4x3
224−-- deriving (Show, Eq)
226−-- Note that right now we're only using Ratio4x3.
227−-- getPageHeight :: PresentationSize -> Pixels
228−-- getPageHeight sz = case presSizeRatio sz of
229−-- Ratio4x3 -> floor (((fromInteger (presSizeWidth sz)) / 4) * 3 :: Double)
230−-- Ratio16x9 -> floor (((fromInteger (presSizeWidth sz)) / 16) * 9 :: Double)
231−-- Ratio16x10 -> floor (((fromInteger (presSizeWidth sz)) / 16) * 10 :: Double)
233−-- instance Default PresentationSize where
234−-- def = PresentationSize 720 Ratio4x3
236data Slide = MetadataSlide { metadataSlideTitle :: [ParaElem]
216data Slide = MetadataSlide { metadataSlideTitle :: [ParaElem]
237 , metadataSlideSubtitle :: [ParaElem]
217 , metadataSlideSubtitle :: [ParaElem]
238 , metadataSlideAuthors :: [[ParaElem]]
218 , metadataSlideAuthors :: [[ParaElem]]
@@ -917,12 +897,71 @@ shapeHasName ns name element
917 nm == name
897 nm == name
918 | otherwise = False
898 | otherwise = False
900+shapeHasId :: NameSpaces -> String -> Element -> Bool
901+shapeHasId ns ident element
902+ | Just nvSpPr <- findChild (elemName ns "p" "nvSpPr") element
903+ , Just cNvPr <- findChild (elemName ns "p" "cNvPr") nvSpPr
904+ , Just nm <- findAttr (QName "id" Nothing Nothing) cNvPr =
920getContentShape :: NameSpaces -> Element -> Maybe Element
908getContentShape :: NameSpaces -> Element -> Maybe Element
921getContentShape ns spTreeElem
909getContentShape ns spTreeElem
922 | isElem ns "p" "spTree" spTreeElem =
910 | isElem ns "p" "spTree" spTreeElem =
923 filterChild (\e -> (isElem ns "p" "sp" e) && (shapeHasName ns "Content Placeholder 2" e)) spTreeElem
911 filterChild (\e -> (isElem ns "p" "sp" e) && (shapeHasName ns "Content Placeholder 2" e)) spTreeElem
924 | otherwise = Nothing
912 | otherwise = Nothing
914+getShapeDimensions :: NameSpaces
916+ -> Maybe ((Integer, Integer), (Integer, Integer))
917+getShapeDimensions ns element
918+ | isElem ns "p" "sp" element = do
919+ spPr <- findChild (elemName ns "p" "spPr") element
920+ xfrm <- findChild (elemName ns "a" "xfrm") spPr
921+ off <- findChild (elemName ns "a" "off") xfrm
922+ xS <- findAttr (QName "x" Nothing Nothing) off
923+ yS <- findAttr (QName "y" Nothing Nothing) off
924+ ext <- findChild (elemName ns "a" "ext") xfrm
925+ cxS <- findAttr (QName "cx" Nothing Nothing) ext
926+ cyS <- findAttr (QName "cy" Nothing Nothing) ext
927+ (x, _) <- listToMaybe $ reads xS
928+ (y, _) <- listToMaybe $ reads yS
929+ (cx, _) <- listToMaybe $ reads cxS
930+ (cy, _) <- listToMaybe $ reads cyS
931+ return $ ((x `div` 12700, y `div` 12700), (cx `div` 12700, cy `div` 12700))
932+ | otherwise = Nothing
935+getMasterShapeDimensionsById :: String
937+ -> Maybe ((Integer, Integer), (Integer, Integer))
938+getMasterShapeDimensionsById ident master = do
939+ let ns = elemToNameSpaces master
940+ cSld <- findChild (elemName ns "p" "cSld") master
941+ spTree <- findChild (elemName ns "p" "spTree") cSld
942+ sp <- filterChild (\e -> (isElem ns "p" "sp" e) && (shapeHasId ns ident e)) spTree
943+ getShapeDimensions ns sp
945+getContentShapeSize :: NameSpaces
948+ -> Maybe ((Integer, Integer), (Integer, Integer))
949+getContentShapeSize ns layout master
950+ | isElem ns "p" "sldLayout" layout
951+ , Just cSld <- findChild (elemName ns "p" "cSld") layout
952+ , Just spTree <- findChild (elemName ns "p" "spTree") cSld
953+ , Just sp <- getContentShape ns spTree
954+ , Just sz <- getShapeDimensions ns sp = Just sz
955+ | isElem ns "p" "sldLayout" layout
956+ , Just cSld <- findChild (elemName ns "p" "cSld") layout
957+ , Just spTree <- findChild (elemName ns "p" "spTree") cSld
958+ , Just sp <- getContentShape ns spTree
959+ , Just ident <- findChild (elemName ns "p" "nvSpPr") sp >>=
960+ findChild (elemName ns "p" "cNvPr") >>=
961+ findAttr (QName "id" Nothing Nothing)
962+ , Just sz <- getMasterShapeDimensionsById ident master = Just sz
963+ | otherwise = Nothing
926replaceNamedChildren :: NameSpaces
965replaceNamedChildren :: NameSpaces
927 -> String
966 -> String
928 -> String
967 -> String
@@ -1036,26 +1075,26 @@ makeMediaEntries = do
1036 let allInfos = mconcat $ M.elems mediaInfos
1075 let allInfos = mconcat $ M.elems mediaInfos
1037 mapM makeMediaEntry allInfos
1076 mapM makeMediaEntry allInfos
1039−-- | Scales the image to fit the page
1078+-- -- | Scales the image to fit the page
1040−-- sizes are passed in emu
1079+-- -- sizes are passed in emu
1041−fitToPage' :: (Double, Double) -- image size in emu
1080+-- fitToPage' :: (Double, Double) -- image size in emu
1042− -> Integer -- pageWidth
1081+-- -> Integer -- pageWidth
1043− -> Integer -- pageHeight
1082+-- -> Integer -- pageHeight
1044− -> (Integer, Integer) -- imagesize
1083+-- -> (Integer, Integer) -- imagesize
1045−fitToPage' (x, y) pageWidth pageHeight
1084+-- fitToPage' (x, y) pageWidth pageHeight
1046− -- Fixes width to the page width and scales the height
1085+-- -- Fixes width to the page width and scales the height
1047− | x <= fromIntegral pageWidth && y <= fromIntegral pageHeight =
1086+-- | x <= fromIntegral pageWidth && y <= fromIntegral pageHeight =
1048− (floor x, floor y)
1087+-- (floor x, floor y)
1049− | x / fromIntegral pageWidth > y / fromIntegral pageWidth =
1088+-- | x / fromIntegral pageWidth > y / fromIntegral pageWidth =
1050− (pageWidth, floor $ ((fromIntegral pageWidth) / x) * y)
1089+-- (pageWidth, floor $ ((fromIntegral pageWidth) / x) * y)
1051− | otherwise =
1090+-- | otherwise =
1052− (floor $ ((fromIntegral pageHeight) / y) * x, pageHeight)
1091+-- (floor $ ((fromIntegral pageHeight) / y) * x, pageHeight)
1054−positionImage :: (Double, Double) -> Integer -> Integer -> (Integer, Integer)
1093+-- positionImage :: (Double, Double) -> Integer -> Integer -> (Integer, Integer)
1055−positionImage (x, y) pageWidth pageHeight =
1094+-- positionImage (x, y) pageWidth pageHeight =
1056− let (x', y') = fitToPage' (x, y) pageWidth pageHeight
1095+-- let (x', y') = fitToPage' (x, y) pageWidth pageHeight
1058− ((pageWidth - x') `div` 2, (pageHeight - y') `div` 2)
1097+-- ((pageWidth - x') `div` 2, (pageHeight - y') `div` 2)
1060getMaster :: PandocMonad m => P m Element
1099getMaster :: PandocMonad m => P m Element
1061getMaster = do
1100getMaster = do
@@ -1067,52 +1106,57 @@ getMaster = do
1067-- image goes underneath it. We only use this in a content slide if it
1106-- image goes underneath it. We only use this in a content slide if it
1068-- has a header.
1107-- has a header.
1070−getHeaderSize :: PandocMonad m => P m ((Integer, Integer), (Integer, Integer))
1109+-- getHeaderSize :: PandocMonad m => P m ((Integer, Integer), (Integer, Integer))
1071−getHeaderSize = do
1110+-- getHeaderSize = do
1072− master <- getMaster
1111+-- master <- getMaster
1073− let ns = elemToNameSpaces master
1112+-- let ns = elemToNameSpaces master
1074− sps = [master] >>=
1113+-- sps = [master] >>=
1075− findChildren (elemName ns "p" "cSld") >>=
1114+-- findChildren (elemName ns "p" "cSld") >>=
1076− findChildren (elemName ns "p" "spTree") >>=
1115+-- findChildren (elemName ns "p" "spTree") >>=
1077− findChildren (elemName ns "p" "sp")
1116+-- findChildren (elemName ns "p" "sp")
1078− mbXfrm =
1117+-- mbXfrm =
1079− listToMaybe (filter (shapeHasName ns "Title Placeholder 1") sps) >>=
1118+-- listToMaybe (filter (shapeHasName ns "Title Placeholder 1") sps) >>=
1080− findChild (elemName ns "p" "spPr") >>=
1119+-- findChild (elemName ns "p" "spPr") >>=
1081− findChild (elemName ns "a" "xfrm")
1120+-- findChild (elemName ns "a" "xfrm")
1082− xoff = mbXfrm >>=
1121+-- xoff = mbXfrm >>=
1083− findChild (elemName ns "a" "off") >>=
1122+-- findChild (elemName ns "a" "off") >>=
1084− findAttr (QName "x" Nothing Nothing) >>=
1123+-- findAttr (QName "x" Nothing Nothing) >>=
1085− (listToMaybe . (\s -> reads s :: [(Integer, String)]))
1124+-- (listToMaybe . (\s -> reads s :: [(Integer, String)]))
1086− yoff = mbXfrm >>=
1125+-- yoff = mbXfrm >>=
1087− findChild (elemName ns "a" "off") >>=
1126+-- findChild (elemName ns "a" "off") >>=
1088− findAttr (QName "y" Nothing Nothing) >>=
1127+-- findAttr (QName "y" Nothing Nothing) >>=
1089− (listToMaybe . (\s -> reads s :: [(Integer, String)]))
1128+-- (listToMaybe . (\s -> reads s :: [(Integer, String)]))
1090− xext = mbXfrm >>=
1129+-- xext = mbXfrm >>=
1091− findChild (elemName ns "a" "ext") >>=
1130+-- findChild (elemName ns "a" "ext") >>=
1092− findAttr (QName "cx" Nothing Nothing) >>=
1131+-- findAttr (QName "cx" Nothing Nothing) >>=
1093− (listToMaybe . (\s -> reads s :: [(Integer, String)]))
1132+-- (listToMaybe . (\s -> reads s :: [(Integer, String)]))
1094− yext = mbXfrm >>=
1133+-- yext = mbXfrm >>=
1095− findChild (elemName ns "a" "ext") >>=
1134+-- findChild (elemName ns "a" "ext") >>=
1096− findAttr (QName "cy" Nothing Nothing) >>=
1135+-- findAttr (QName "cy" Nothing Nothing) >>=
1097− (listToMaybe . (\s -> reads s :: [(Integer, String)]))
1136+-- (listToMaybe . (\s -> reads s :: [(Integer, String)]))
1098− off = case xoff of
1137+-- off = case xoff of
1099− Just (xoff', _) | Just (yoff',_) <- yoff -> (xoff', yoff')
1138+-- Just (xoff', _) | Just (yoff',_) <- yoff -> (xoff', yoff')
1100− _ -> (1043490, 1027664)
1139+-- _ -> (1043490, 1027664)
1101− ext = case xext of
1140+-- ext = case xext of
1102− Just (xext', _) | Just (yext',_) <- yext -> (xext', yext')
1141+-- Just (xext', _) | Just (yext',_) <- yext -> (xext', yext')
1103− _ -> (7024744, 1143000)
1142+-- _ -> (7024744, 1143000)
1104− return $ (off, ext)
1143+-- return $ (off, ext)
1107-- Hard-coded for now
1145-- Hard-coded for now
1108−captionPosition :: ((Integer, Integer), (Integer, Integer))
1146+-- captionPosition :: ((Integer, Integer), (Integer, Integer))
1109−captionPosition = ((457200, 6061972), (8229600, 527087))
1147+-- captionPosition = ((457200, 6061972), (8229600, 527087))
1149+captionHeight :: Integer
1111−createCaption :: PandocMonad m => [ParaElem] -> P m Element
1152+createCaption :: PandocMonad m
1153+ => ((Integer, Integer), (Integer, Integer))
1112−createCaption paraElements = do
1156+createCaption contentShapeDimensions paraElements = do
1113 let para = Paragraph def{pPropAlign = Just AlgnCenter} paraElements
1157 let para = Paragraph def{pPropAlign = Just AlgnCenter} paraElements
1114 elements <- mapM paragraphToElement [para]
1158 elements <- mapM paragraphToElement [para]
1115− let ((x, y), (cx, cy)) = captionPosition
1159+ let ((x, y), (cx, cy)) = contentShapeDimensions
1116 let txBody = mknode "p:txBody" [] $
1160 let txBody = mknode "p:txBody" [] $
1117 [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] ++ elements
1161 [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] ++ elements
1118 return $
1162 return $
@@ -1123,8 +1167,10 @@ createCaption paraElements = do
1124 , mknode "p:spPr" []
1168 , mknode "p:spPr" []
1125 [ mknode "a:xfrm" []
1169 [ mknode "a:xfrm" []
1126− [ mknode "a:off" [("x", show x), ("y", show y)] ()
1170+ [ mknode "a:off" [("x", show $ 12700 * x),
1171+ ("y", show $ 12700 * (y + cy - captionHeight))] ()
1127− , mknode "a:ext" [("cx", show cx), ("cy", show cy)] ()
1172+ , mknode "a:ext" [("cx", show $ 12700 * cx),
1173+ ("cy", show $ 12700 * captionHeight)] ()
1129 , mknode "a:prstGeom" [("prst", "rect")]
1175 , mknode "a:prstGeom" [("prst", "rect")]
1130 [ mknode "a:avLst" [] ()
1176 [ mknode "a:avLst" [] ()
@@ -1134,37 +1180,41 @@ createCaption paraElements = do
1134 , txBody
1180 , txBody
1137−-- Largely lifted from inlineToOpenXML' in T.P.W.Docx. Can't be easily
1138−-- abstracted because of some different namespaces and monads. TODO.
1139−makePicElement :: PandocMonad m
1183+makePicElements :: PandocMonad m
1140− => PicProps
1185+ -> PicProps
1141− -> MediaInfo
1186+ -> MediaInfo
1142− -> Text.Pandoc.Definition.Attr
1187+ -> Text.Pandoc.Definition.Attr
1143− -> P m Element
1189+ -> P m [Element]
1144−makePicElement picProps mInfo attr = do
1190+makePicElements layout picProps mInfo _ alt = do
1145 opts <- asks envOpts
1191 opts <- asks envOpts
1146 (pageWidth, pageHeight) <- asks envPresentationSize
1192 (pageWidth, pageHeight) <- asks envPresentationSize
1147− hasHeader <- asks envSlideHasHeader
1193+ -- hasHeader <- asks envSlideHasHeader
1148 let hasCaption = mInfoCaption mInfo
1194 let hasCaption = mInfoCaption mInfo
1149 (imgBytes, _) <- P.fetchItem (mInfoFilePath mInfo)
1195 (imgBytes, _) <- P.fetchItem (mInfoFilePath mInfo)
1150− -- We're not using x exts
1151− ((hXoff, hYoff), (_, hYext)) <- if hasHeader
1153− else return ((0, 0), (0, 0))
1155− let ((capX, capY), (_, _)) = if hasCaption
1156− then captionPosition
1157− else ((0,0), (0,0))
1158− let (xpt,ypt) = desiredSizeInPoints opts attr
1159− (either (const def) id (imageSize opts imgBytes))
1196+ let (pxX, pxY) = case imageSize opts imgBytes of
1160− -- 12700 emu = 1 pt
1197+ Right sz -> sizeInPixels $ sz
1161− let (xemu,yemu) = fitToPage' (xpt * 12700, ypt * 12700)
1198+ Left _ -> sizeInPixels $ def
1162− ((pageWidth * 12700) - (2 * hXoff) - (2 * capX))
1199+ master <- getMaster
1200+ let ns = elemToNameSpaces layout
1201+ let ((x, y), (cx, cytmp)) = case getContentShapeSize ns layout master of
1203+ Nothing -> ((0, 0), (pageWidth, pageHeight))
1163− ((if hasCaption then capY else (pageHeight * 12700)) - (hYoff + hYext))
1205+ cy = if hasCaption then cytmp - captionHeight else cytmp
1164− (xoff, yoff) = positionImage (xpt * 12700, ypt * 12700) (pageWidth * 12700) (pageHeight * 12700)
1206+
1165− xoff' = if hasHeader then xoff + hXoff else xoff
1207+ let imgRatio = fromIntegral pxX / fromIntegral pxY :: Double
1166− xoff'' = if hasCaption then xoff' + capX else xoff'
1208+ boxRatio = fromIntegral cx / fromIntegral cy :: Double
1167− yoff' = if hasHeader then hYoff + hYext else yoff
1209+ (dimX, dimY) = if imgRatio > boxRatio
1210+ then (fromIntegral cx, fromIntegral cx / imgRatio)
1211+ else (fromIntegral cy * imgRatio, fromIntegral cy)
1213+ (dimX', dimY') = (round dimX * 12700, round dimY * 12700) :: (Integer, Integer)
1214+ (xoff, yoff) = (fromIntegral x + (fromIntegral cx - dimX) / 2,
1215+ fromIntegral y + (fromIntegral cy - dimY) / 2)
1216+ (xoff', yoff') = (round xoff * 12700, round yoff * 12700) :: (Integer, Integer)
1168 let cNvPicPr = mknode "p:cNvPicPr" [] $
1218 let cNvPicPr = mknode "p:cNvPicPr" [] $
1169 mknode "a:picLocks" [("noGrp","1")
1219 mknode "a:picLocks" [("noGrp","1")
1170 ,("noChangeAspect","1")] ()
1220 ,("noChangeAspect","1")] ()
@@ -1185,9 +1235,9 @@ makePicElement picProps mInfo attr = do
1185 , mknode "a:stretch" [] $
1235 , mknode "a:stretch" [] $
1186 mknode "a:fillRect" [] () ]
1236 mknode "a:fillRect" [] () ]
1187 let xfrm = mknode "a:xfrm" []
1237 let xfrm = mknode "a:xfrm" []
1188− [ mknode "a:off" [("x",show xoff''), ("y",show yoff')] ()
1238+ [ mknode "a:off" [("x",show xoff'), ("y",show yoff')] ()
1189− , mknode "a:ext" [("cx",show xemu)
1239+ , mknode "a:ext" [("cx",show dimX')
1190− ,("cy",show yemu)] () ]
1240+ ,("cy",show dimY')] () ]
1191 let prstGeom = mknode "a:prstGeom" [("prst","rect")] $
1241 let prstGeom = mknode "a:prstGeom" [("prst","rect")] $
1192 mknode "a:avLst" [] ()
1242 mknode "a:avLst" [] ()
1193 let ln = mknode "a:ln" [("w","9525")]
1243 let ln = mknode "a:ln" [("w","9525")]
@@ -1196,11 +1246,17 @@ makePicElement picProps mInfo attr = do
1196 , mknode "a:tailEnd" [] () ]
1246 , mknode "a:tailEnd" [] () ]
1197 let spPr = mknode "p:spPr" [("bwMode","auto")]
1247 let spPr = mknode "p:spPr" [("bwMode","auto")]
1198 [xfrm, prstGeom, mknode "a:noFill" [] (), ln]
1248 [xfrm, prstGeom, mknode "a:noFill" [] (), ln]
1200− mknode "p:pic" []
1250+ let picShape = mknode "p:pic" []
1201− [ nvPicPr
1251+ [ nvPicPr
1202− , blipFill
1252+ , blipFill
1203− , spPr ]
1253+ , spPr ]
1255+ -- And now, maybe create the caption:
1257+ then do cap <- createCaption ((x, y), (cx, cytmp)) alt
1258+ return [picShape, cap]
1259+ else return [picShape]
1205-- Currently hardcoded, until I figure out how to make it dynamic.
1261-- Currently hardcoded, until I figure out how to make it dynamic.
1206blockQuoteSize :: Pixels
1262blockQuoteSize :: Pixels
@@ -1345,44 +1401,21 @@ shapeToElement layout (TextBox paras)
1345 replaceNamedChildren ns "p" "txBody" [txBody] $
1401 replaceNamedChildren ns "p" "txBody" [txBody] $
1346 replaceNamedChildren ns "p" "spPr" [emptySpPr] $
1402 replaceNamedChildren ns "p" "spPr" [emptySpPr] $
1348− -- XXX: TODO
1404+-- GraphicFrame and Pic should never reach this.
1349− | otherwise = return $ mknode "p:sp" [] ()
1405+shapeToElement _ _ = return $ mknode "p:sp" [] ()
1351−shapeToElement layout (Pic picProps fp attr alt) = do
1352− mInfo <- registerMedia fp alt
1353− case mInfoExt mInfo of
1354− Just _ -> makePicElement picProps mInfo attr
1355− Nothing -> shapeToElement layout $ TextBox [Paragraph def alt]
1356−shapeToElement _ (GraphicFrame tbls _) = do
1357− elements <- mapM graphicToElement tbls
1358− return $ mknode "p:graphicFrame" [] $
1359− [ mknode "p:nvGraphicFramePr" [] $
1360− [ mknode "p:cNvPr" [("id", "6"), ("name", "Content Placeholder 5")] ()
1361− , mknode "p:cNvGraphicFramePr" [] $
1362− [mknode "a:graphicFrameLocks" [("noGrp", "1")] ()]
1363− , mknode "p:nvPr" [] $
1364− [mknode "p:ph" [("idx", "1")] ()]
1366− , mknode "p:xfrm" [] $
1367− [ mknode "a:off" [("x", "457200"), ("y", "1600200")] ()
1368− , mknode "a:ext" [("cx", "8029388"), ("cy", "3644152")] ()
1372shapeToElements :: PandocMonad m => Element -> Shape -> P m [Element]
1407shapeToElements :: PandocMonad m => Element -> Shape -> P m [Element]
1408+shapeToElements layout (Pic picProps fp attr alt) = do
1409+ mInfo <- registerMedia fp alt
1410+ case mInfoExt mInfo of
1412+ makePicElements layout picProps mInfo attr alt
1413+ Nothing -> shapeToElements layout $ TextBox [Paragraph def alt]
1414+shapeToElements layout (GraphicFrame tbls cptn) =
1415+ graphicFrameToElements layout tbls cptn
1373shapeToElements layout shp = do
1416shapeToElements layout shp = do
1375− (Pic _ _ _ alt) | (not . null) alt -> do
1376− element <- shapeToElement layout shp
1417+ element <- shapeToElement layout shp
1377− caption <- createCaption alt
1378− return [element, caption]
1379− (GraphicFrame _ cptn) | (not . null) cptn -> do
1380− element <- shapeToElement layout shp
1381− caption <- createCaption cptn
1382− return [element, caption]
1384− element <- shapeToElement layout shp
1385− return [element]
1418+ return [element]
1387shapesToElements :: PandocMonad m => Element -> [Shape] -> P m [Element]
1420shapesToElements :: PandocMonad m => Element -> [Shape] -> P m [Element]
1388shapesToElements layout shps = do
1421shapesToElements layout shps = do
@@ -1391,6 +1424,38 @@ shapesToElements layout shps = do
1391hardcodedTableMargin :: Integer
1424hardcodedTableMargin :: Integer
1392hardcodedTableMargin = 36
1425hardcodedTableMargin = 36
1427+graphicFrameToElements :: PandocMonad m => Element -> [Graphic] -> [ParaElem] -> P m [Element]
1428+graphicFrameToElements layout tbls caption = do
1430+ master <- getMaster
1431+ (pageWidth, pageHeight) <- asks envPresentationSize
1432+ let ns = elemToNameSpaces layout
1433+ let ((x, y), (cx, cytmp)) = case getContentShapeSize ns layout master of
1435+ Nothing -> ((0, 0), (pageWidth, pageHeight))
1437+ cy = if (not $ null caption) then cytmp - captionHeight else cytmp
1439+ elements <- mapM graphicToElement tbls
1440+ let graphicFrameElts =
1441+ mknode "p:graphicFrame" [] $
1442+ [ mknode "p:nvGraphicFramePr" [] $
1443+ [ mknode "p:cNvPr" [("id", "6"), ("name", "Content Placeholder 5")] ()
1444+ , mknode "p:cNvGraphicFramePr" [] $
1445+ [mknode "a:graphicFrameLocks" [("noGrp", "1")] ()]
1446+ , mknode "p:nvPr" [] $
1447+ [mknode "p:ph" [("idx", "1")] ()]
1449+ , mknode "p:xfrm" [] $
1450+ [ mknode "a:off" [("x", show $ 12700 * x), ("y", show $ 12700 * y)] ()
1451+ , mknode "a:ext" [("cx", show $ 12700 * cx), ("cy", show $ 12700 * cy)] ()
1455+ if (not $ null caption)
1456+ then do capElt <- createCaption ((x, y), (cx, cytmp)) caption
1457+ return [graphicFrameElts, capElt]
1458+ else return [graphicFrameElts]
1395graphicToElement :: PandocMonad m => Graphic -> P m Element
1460graphicToElement :: PandocMonad m => Graphic -> P m Element
1396graphicToElement (Tbl tblPr colWidths hdrCells rows) = do
1461graphicToElement (Tbl tblPr colWidths hdrCells rows) = do
@@ -1437,6 +1502,12 @@ getShapeByName ns spTreeElem name
1437 filterChild (\e -> (isElem ns "p" "sp" e) && (shapeHasName ns name e)) spTreeElem
1502 filterChild (\e -> (isElem ns "p" "sp" e) && (shapeHasName ns name e)) spTreeElem
1438 | otherwise = Nothing
1503 | otherwise = Nothing
1505+-- getShapeById :: NameSpaces -> Element -> String -> Maybe Element
1506+-- getShapeById ns spTreeElem ident
1507+-- | isElem ns "p" "spTree" spTreeElem =
1508+-- filterChild (\e -> (isElem ns "p" "sp" e) && (shapeHasId ns ident e)) spTreeElem
1509+-- | otherwise = Nothing
1440nonBodyTextToElement :: PandocMonad m => Element -> String -> [ParaElem] -> P m Element
1511nonBodyTextToElement :: PandocMonad m => Element -> String -> [ParaElem] -> P m Element
1441nonBodyTextToElement layout shapeName paraElements
1512nonBodyTextToElement layout shapeName paraElements
1442 | ns <- elemToNameSpaces layout
1513 | ns <- elemToNameSpaces layout