@@ -56,7 +56,7 @@ import Text.Pandoc.XML
5656import Text.TeXMath
5757import Text.XML.Light
5858
59−data ODTState = ODTState { stEntries :: [Entry]
59+newtype ODTState = ODTState { stEntries :: [Entry]
6060 }
6161
6262type O m = StateT ODTState m
@@ -224,17 +224,39 @@ transformPicMath _ (Math t math) = do
224224 let dirname = "Formula-" ++ show (length entries) ++ "/"
225225 let fname = dirname ++ "content.xml"
226226 let entry = toEntry fname epochtime (fromStringLazy mathml)
227− modify $ \st -> st{ stEntries = entry : entries }
227+ let fname' = dirname ++ "settings.xml"
228+ let entry' = toEntry fname' epochtime $ documentSettings (t == InlineMath)
229+ modify $ \st -> st{ stEntries = entry' : (entry : entries) }
228230 return $ RawInline (Format "opendocument") $ render Nothing $
229− inTags False "draw:frame" [("text:anchor-type",
230− if t == DisplayMath
231− then "paragraph"
232− else "as-char")
233− ,("style:vertical-pos", "middle")
234− ,("style:vertical-rel", "text")] $
231+ inTags False "draw:frame" (if t == DisplayMath
232+ then [("draw:style-name","fr2")
233+ -- `draw:frame` does not support either
234+ -- `style:vertical-pos` or `style:vertical-rel`,
235+ -- therefore those attributes must go into the
236+ -- `style:style` element
237+ ,("text:anchor-type","paragraph")]
238+ else [("draw:style-name","fr1")
239+ ,("text:anchor-type","as-char")]) $
235240 selfClosingTag "draw:object" [("xlink:href", dirname)
236241 , ("xlink:type", "simple")
237242 , ("xlink:show", "embed")
238243 , ("xlink:actuate", "onLoad")]
239244
240245transformPicMath _ x = return x
246+
247+documentSettings :: Bool -> B.ByteString
248+documentSettings isTextMode = fromStringLazy $ render Nothing
249+ $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
250+ $$
251+ (inTags True "office:document-settings"
252+ [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0")
253+ ,("xmlns:xlink","http://www.w3.org/1999/xlink")
254+ ,("xmlns:config","urn:oasis:names:tc:opendocument:xmlns:config:1.0")
255+ ,("xmlns:ooo","http://openoffice.org/2004/office")
256+ ,("office:version","1.2")] $
257+ inTagsSimple "office:settings" $
258+ inTags False "config:config-item-set"
259+ [("config:name", "ooo:configuration-settings")] $
260+ inTags False "config:config-item" [("config:name", "IsTextMode")
261+ ,("config:type", "boolean")] $
262+ text $ if isTextMode then "true" else "false")