summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2018-02-27 10:19:35 -0500
committerJesse Rosenthal <jrosenthal@jhu.edu>2018-02-27 10:19:35 -0500
commit9abcb4f2010348ae7d25a2199d8e7fcb91a6315d (patch)
tree052173e7f511e3642a8ad0ddc92aad28cbffa84b
parentcdaa80e718ac177fb355819fc48c57f77d2a6bd1 (diff)
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.
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint/Output.hs20
-rw-r--r--test/pptx/tables.pptxbin27175 -> 27282 bytes
-rw-r--r--test/pptx/tables_templated.pptxbin394504 -> 394610 bytes
3 files changed, 17 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint/Output.hs b/src/Text/Pandoc/Writers/Powerpoint/Output.hs
index b5138b514..410b6c20c 100644
--- a/src/Text/Pandoc/Writers/Powerpoint/Output.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint/Output.hs
@@ -930,6 +930,13 @@ graphicFrameToElements layout tbls caption = do
return [graphicFrameElts, capElt]
else return [graphicFrameElts]
+getDefaultTableStyle :: PandocMonad m => P m (Maybe String)
+getDefaultTableStyle = do
+ refArchive <- asks envRefArchive
+ distArchive <- asks envDistArchive
+ tblStyleLst <- parseXml refArchive distArchive "ppt/tableStyles.xml"
+ return $ findAttr (QName "def" Nothing Nothing) tblStyleLst
+
graphicToElement :: PandocMonad m => Integer -> Graphic -> P m Element
graphicToElement tableWidth (Tbl tblPr hdrCells rows) = do
let colWidths = if null hdrCells
@@ -967,12 +974,19 @@ graphicToElement tableWidth (Tbl tblPr hdrCells rows) = do
let mkgridcol w = mknode "a:gridCol"
[("w", show ((12700 * w) :: Integer))] ()
let hasHeader = not (all null hdrCells)
+
+ mbDefTblStyle <- getDefaultTableStyle
+ let tblPrElt = mknode "a:tblPr"
+ [ ("firstRow", if tblPrFirstRow tblPr then "1" else "0")
+ , ("bandRow", if tblPrBandRow tblPr then "1" else "0")
+ ] (case mbDefTblStyle of
+ Nothing -> []
+ Just sty -> [mknode "a:tableStyleId" [] sty])
+
return $ mknode "a:graphic" [] $
[mknode "a:graphicData" [("uri", "http://schemas.openxmlformats.org/drawingml/2006/table")] $
[mknode "a:tbl" [] $
- [ mknode "a:tblPr" [ ("firstRow", if tblPrFirstRow tblPr then "1" else "0")
- , ("bandRow", if tblPrBandRow tblPr then "1" else "0")
- ] ()
+ [ tblPrElt
, mknode "a:tblGrid" [] (if all (==0) colWidths
then []
else map mkgridcol colWidths)
diff --git a/test/pptx/tables.pptx b/test/pptx/tables.pptx
index 0e8aea9ba..c3e215a30 100644
--- a/test/pptx/tables.pptx
+++ b/test/pptx/tables.pptx
Binary files differ
diff --git a/test/pptx/tables_templated.pptx b/test/pptx/tables_templated.pptx
index 0ae560ad3..46f72edab 100644
--- a/test/pptx/tables_templated.pptx
+++ b/test/pptx/tables_templated.pptx
Binary files differ