pptx: Fix logic for choosing Comparison layout
There was a mistake in the logic used to choose between the Comparison and Two Content layouts: if one column contained only non-text (an image or a table) and the other contained only text, the Comparison layout was chosen instead of the desired Two Content layout. This commit fixes that logic: > If either column contains text followed by non-text, use Comparison. Otherwise, use Two Content. It also adds a test asserting this behaviour.
This commit is contained in:
parent
6271b09c50
commit
0ebe65e651
13 changed files with 27 additions and 8 deletions
|
@ -446,8 +446,10 @@ extra-source-files:
|
|||
test/pptx/start-numbering-at/*.pptx
|
||||
test/pptx/tables/input.native
|
||||
test/pptx/tables/*.pptx
|
||||
test/pptx/two-column/input.native
|
||||
test/pptx/two-column/*.pptx
|
||||
test/pptx/two-column/all-text/input.native
|
||||
test/pptx/two-column/all-text/*.pptx
|
||||
test/pptx/two-column/text-and-image/input.native
|
||||
test/pptx/two-column/text-and-image/*.pptx
|
||||
test/ipynb/*.in.native
|
||||
test/ipynb/*.out.native
|
||||
test/ipynb/*.ipynb
|
||||
|
|
|
@ -696,10 +696,11 @@ bodyBlocksToSlide _ (blk : blks) spkNotes
|
|||
sldId
|
||||
(ComparisonSlide [] (shapesL1, shapesL2) (shapesR1, shapesR2))
|
||||
spkNotes
|
||||
case (break notText blksL, break notText blksR) of
|
||||
((_, []), (_, [])) -> mkTwoColumn blksL blksR
|
||||
(([], _), ([], _)) -> mkTwoColumn blksL blksR
|
||||
((blksL1, blksL2), (blksR1, blksR2)) -> mkComparison blksL1 blksL2 blksR1 blksR2
|
||||
let (blksL1, blksL2) = break notText blksL
|
||||
(blksR1, blksR2) = break notText blksR
|
||||
if (any null [blksL1, blksL2]) && (any null [blksR1, blksR2])
|
||||
then mkTwoColumn blksL blksR
|
||||
else mkComparison blksL1 blksL2 blksR1 blksR2
|
||||
bodyBlocksToSlide _ (blk : blks) spkNotes = do
|
||||
sldId <- asks envCurSlideId
|
||||
inNoteSlide <- asks envInNoteSlide
|
||||
|
|
|
@ -103,8 +103,12 @@ tests = groupPptxTests [ pptxTests "Inline formatting"
|
|||
"pptx/images/output.pptx"
|
||||
, pptxTests "two-column layout"
|
||||
def
|
||||
"pptx/two-column/input.native"
|
||||
"pptx/two-column/output.pptx"
|
||||
"pptx/two-column/all-text/input.native"
|
||||
"pptx/two-column/all-text/output.pptx"
|
||||
, pptxTests "two-column (not comparison)"
|
||||
def
|
||||
"pptx/two-column/text-and-image/input.native"
|
||||
"pptx/two-column/text-and-image/output.pptx"
|
||||
, pptxTests "speaker notes"
|
||||
def
|
||||
"pptx/speaker-notes/input.native"
|
||||
|
|
BIN
test/pptx/two-column/text-and-image/deleted-layouts.pptx
Normal file
BIN
test/pptx/two-column/text-and-image/deleted-layouts.pptx
Normal file
Binary file not shown.
12
test/pptx/two-column/text-and-image/input.native
Normal file
12
test/pptx/two-column/text-and-image/input.native
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Header 1 ("slide-1",[],[]) [Str "Slide",Space,Str "1"]
|
||||
,Div ("",["columns"],[])
|
||||
[Div ("",["column"],[])
|
||||
[Para [Image ("",[],[]) [Str "an",Space,Str "image"] ("lalune.jpg","fig:")]]
|
||||
,Div ("",["column"],[])
|
||||
[Para [Str "This",Space,Str "should",Space,Str "use",Space,Str "Two",Space,Str "Content,",Space,Emph [Str "not"],Space,Str "Comparison!"]]]
|
||||
,Header 1 ("slide-2",[],[]) [Str "Slide",Space,Str "2"]
|
||||
,Div ("",["columns"],[])
|
||||
[Div ("",["column"],[])
|
||||
[Para [Str "This",Space,Str "should",Space,Str "also",Space,Str "use",Space,Str "Two",Space,Str "Content"]]
|
||||
,Div ("",["column"],[])
|
||||
[Para [Image ("",[],[]) [Str "an",Space,Str "image"] ("lalune.jpg","fig:")]]]]
|
BIN
test/pptx/two-column/text-and-image/moved-layouts.pptx
Normal file
BIN
test/pptx/two-column/text-and-image/moved-layouts.pptx
Normal file
Binary file not shown.
BIN
test/pptx/two-column/text-and-image/output.pptx
Normal file
BIN
test/pptx/two-column/text-and-image/output.pptx
Normal file
Binary file not shown.
BIN
test/pptx/two-column/text-and-image/templated.pptx
Normal file
BIN
test/pptx/two-column/text-and-image/templated.pptx
Normal file
Binary file not shown.
Loading…
Reference in a new issue