summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArlo O'Keeffe <MailToArlo@googlemail.com>2012-07-13 15:19:39 -0600
committerArlo O'Keeffe <MailToArlo@googlemail.com>2012-07-13 15:19:39 -0600
commitd25656571a4662a4e67b195daed69e77d80c4c2c (patch)
treea1687eb193c35a6f95aaa8f2e1da4365d610f69b
parent5c56165555545ac8091f4d8b316a16ca8c09f975 (diff)
Set ODT title property
-rw-r--r--src/Text/Pandoc/Writers/ODT.hs24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
index f8f22494f..9e3dba98a 100644
--- a/src/Text/Pandoc/Writers/ODT.hs
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -36,7 +36,7 @@ import Data.ByteString.Lazy.UTF8 ( fromString )
import Codec.Archive.Zip
import Data.Time.Clock.POSIX
import Paths_pandoc ( getDataFileName )
-import Text.Pandoc.Shared ( WriterOptions(..) )
+import Text.Pandoc.Shared hiding (Element)
import Text.Pandoc.ImageSize ( readImageSize, sizeInPoints )
import Text.Pandoc.MIME ( getMimeType )
import Text.Pandoc.Definition
@@ -53,7 +53,7 @@ writeODT :: Maybe FilePath -- ^ Path specified by --reference-odt
-> WriterOptions -- ^ Writer options
-> Pandoc -- ^ Document to convert
-> IO B.ByteString
-writeODT mbRefOdt opts doc = do
+writeODT mbRefOdt opts doc@(Pandoc (Meta title _ _) _) = do
let datadir = writerUserDataDir opts
refArchive <- liftM toArchive $
case mbRefOdt of
@@ -98,7 +98,25 @@ writeODT mbRefOdt opts doc = do
)
)
let archive' = addEntryToArchive manifestEntry archive
- return $ fromArchive archive'
+ let metaEntry = toEntry "meta.xml" epochtime
+ $ fromString $ show
+ $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ $$
+ ( inTags True "office:document-meta"
+ [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0")
+ ,("xmlns:xlink","http://www.w3.org/1999/xlink")
+ ,("xmlns:dc","http://purl.org/dc/elements/1.1/")
+ ,("xmlns:meta","urn:oasis:names:tc:opendocument:xmlns:meta:1.0")
+ ,("xmlns:ooo","http://openoffice.org/2004/office")
+ ,("xmlns:grddl","http://www.w3.org/2003/g/data-view#")
+ ,("office:version","1.2")]
+ $ ( inTagsSimple "office:meta"
+ $ ( inTagsSimple "dc:title" (text $ escapeStringForXML (stringify title))
+ )
+ )
+ )
+ let archive'' = addEntryToArchive metaEntry archive'
+ return $ fromArchive archive''
transformPic :: FilePath -> IORef [Entry] -> Inline -> IO Inline
transformPic sourceDir entriesRef (Image lab (src,tit)) = do