git.iko.soy/typeable/pandoc
on master help sign in
Powerpoint writer: Use table styles

This will use the default table style in the reference-doc file. As a result they will be easier when using in a template, and match the color scheme.

commit9abcb4f2010348ae7d25a2199d8e7fcb91a6315d authorJesse Rosenthal <jrosenthal@jhu.edu> dateTue 27 Feb 2018, 10:19 (9 years ago) parentcdaa80e
3 files changed+17−3
src/Text/Pandoc/Writers/Powerpoint/Output.hs+17−3 test/pptx/tables.pptx test/pptx/tables_templated.pptx
src/Text/Pandoc/Writers/Powerpoint/Output.hs+17−3
@@ -930,6 +930,13 @@ graphicFrameToElements layout tbls caption = do
930930 return [graphicFrameElts, capElt]
931931 else return [graphicFrameElts]
932932
933+getDefaultTableStyle :: PandocMonad m => P m (Maybe String)
934+getDefaultTableStyle = do
935+ refArchive <- asks envRefArchive
936+ distArchive <- asks envDistArchive
937+ tblStyleLst <- parseXml refArchive distArchive "ppt/tableStyles.xml"
938+ return $ findAttr (QName "def" Nothing Nothing) tblStyleLst
939+
933940graphicToElement :: PandocMonad m => Integer -> Graphic -> P m Element
934941graphicToElement tableWidth (Tbl tblPr hdrCells rows) = do
935942 let colWidths = if null hdrCells
@@ -967,12 +974,19 @@ graphicToElement tableWidth (Tbl tblPr hdrCells rows) = do
967974 let mkgridcol w = mknode "a:gridCol"
968975 [("w", show ((12700 * w) :: Integer))] ()
969976 let hasHeader = not (all null hdrCells)
977+
978+ mbDefTblStyle <- getDefaultTableStyle
979+ let tblPrElt = mknode "a:tblPr"
980+ [ ("firstRow", if tblPrFirstRow tblPr then "1" else "0")
981+ , ("bandRow", if tblPrBandRow tblPr then "1" else "0")
982+ ] (case mbDefTblStyle of
983+ Nothing -> []
984+ Just sty -> [mknode "a:tableStyleId" [] sty])
985+
970986 return $ mknode "a:graphic" [] $
971987 [mknode "a:graphicData" [("uri", "http://schemas.openxmlformats.org/drawingml/2006/table")] $
972988 [mknode "a:tbl" [] $
973− [ mknode "a:tblPr" [ ("firstRow", if tblPrFirstRow tblPr then "1" else "0")
974− , ("bandRow", if tblPrBandRow tblPr then "1" else "0")
975− ] ()
989+ [ tblPrElt
976990 , mknode "a:tblGrid" [] (if all (==0) colWidths
977991 then []
978992 else map mkgridcol colWidths)
test/pptx/tables.pptx

Binary file not shown.

test/pptx/tables_templated.pptx

Binary file not shown.