From cdaa80e718ac177fb355819fc48c57f77d2a6bd1 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Tue, 27 Feb 2018 09:34:24 -0500 Subject: Powerpoint writer: add test for table and list syntax These were never added when the tests were first created. Output files checked in MS PowerPoint 2013 (Windows 10, VBox). No corruption, and output as expected. --- test/pptx/tables.pptx | Bin 0 -> 27175 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/pptx/tables.pptx (limited to 'test/pptx/tables.pptx') diff --git a/test/pptx/tables.pptx b/test/pptx/tables.pptx new file mode 100644 index 000000000..0e8aea9ba Binary files /dev/null and b/test/pptx/tables.pptx differ -- cgit v1.2.3 From 9abcb4f2010348ae7d25a2199d8e7fcb91a6315d Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Tue, 27 Feb 2018 10:19:35 -0500 Subject: 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. --- src/Text/Pandoc/Writers/Powerpoint/Output.hs | 20 +++++++++++++++++--- test/pptx/tables.pptx | Bin 27175 -> 27282 bytes test/pptx/tables_templated.pptx | Bin 394504 -> 394610 bytes 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'test/pptx/tables.pptx') 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 Binary files a/test/pptx/tables.pptx and b/test/pptx/tables.pptx differ diff --git a/test/pptx/tables_templated.pptx b/test/pptx/tables_templated.pptx index 0ae560ad3..46f72edab 100644 Binary files a/test/pptx/tables_templated.pptx and b/test/pptx/tables_templated.pptx differ -- cgit v1.2.3