@@ -1,4 +1,3 @@
1−{-# LANGUAGE TemplateHaskell #-}
3Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
2Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
@@ -29,7 +28,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29Functions for producing an ODT file from OpenDocument XML.
28Functions for producing an ODT file from OpenDocument XML.
31module Text.Pandoc.ODT ( saveOpenDocumentAsODT ) where
30module Text.Pandoc.ODT ( saveOpenDocumentAsODT ) where
32−import Text.Pandoc.TH ( makeZip )
33import Data.List ( find )
31import Data.List ( find )
34import System.FilePath ( (</>), takeFileName )
32import System.FilePath ( (</>), takeFileName )
35import qualified Data.ByteString.Lazy as B
33import qualified Data.ByteString.Lazy as B
@@ -39,6 +37,8 @@ import Codec.Archive.Zip
39import Control.Applicative ( (<$>) )
37import Control.Applicative ( (<$>) )
40import Text.ParserCombinators.Parsec
38import Text.ParserCombinators.Parsec
41import System.Time
39import System.Time
40+import Text.Pandoc.Shared ( inDirectory )
41+import Paths_pandoc ( getDataFileName )
43-- | Produce an ODT file from OpenDocument XML.
43-- | Produce an ODT file from OpenDocument XML.
44saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
44saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
@@ -46,7 +46,9 @@ saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
46 -> String -- ^ OpenDocument XML contents.
46 -> String -- ^ OpenDocument XML contents.
48saveOpenDocumentAsODT destinationODTPath sourceDirRelative xml = do
48saveOpenDocumentAsODT destinationODTPath sourceDirRelative xml = do
49− let refArchive = read $(makeZip $ "data" </> "odt-styles")
49+ refArchivePath <- getDataFileName $ "data" </> "odt-styles"
50+ refArchive <- inDirectory refArchivePath $
51+ addFilesToArchive [OptRecursive] emptyArchive ["."]
50 -- handle pictures
52 -- handle pictures
51 let (newContents, pics) =
53 let (newContents, pics) =
52 case runParser pPictures [] "OpenDocument XML contents" xml of
54 case runParser pPictures [] "OpenDocument XML contents" xml of