@@ -42,22 +42,25 @@ import System.Directory
42import Control.Monad (liftM)
42import Control.Monad (liftM)
44-- | Produce an ODT file from OpenDocument XML.
44-- | Produce an ODT file from OpenDocument XML.
45−saveOpenDocumentAsODT :: FilePath -- ^ Path of user data directory
45+saveOpenDocumentAsODT :: Maybe FilePath -- ^ Path of user data directory
46− -> FilePath -- ^ Pathname of ODT file to be produced.
46+ -> FilePath -- ^ Pathname of ODT file to be produced
47− -> FilePath -- ^ Relative directory of source file.
47+ -> FilePath -- ^ Relative directory of source file
48 -> Maybe FilePath -- ^ Path specified by --reference-odt
48 -> Maybe FilePath -- ^ Path specified by --reference-odt
49− -> String -- ^ OpenDocument XML contents.
49+ -> String -- ^ OpenDocument XML contents
51saveOpenDocumentAsODT datadir destinationODTPath sourceDirRelative mbRefOdt xml = do
51saveOpenDocumentAsODT datadir destinationODTPath sourceDirRelative mbRefOdt xml = do
52 refArchive <- liftM toArchive $
52 refArchive <- liftM toArchive $
53 case mbRefOdt of
53 case mbRefOdt of
54 Just f -> B.readFile f
54 Just f -> B.readFile f
55 Nothing -> do
55 Nothing -> do
56− let userRefOdt = datadir </> "reference.odt"
56+ let defaultODT = getDataFileName "reference.odt" >>= B.readFile
57− userRefOdtExists <- doesFileExist userRefOdt
57+ case datadir of
58− if userRefOdtExists
58+ Nothing -> defaultODT
60+ exists <- doesFileExist (d </> "reference.odt")
59− then B.readFile userRefOdt
62+ then B.readFile (d </> "reference.odt")
60− else getDataFileName "reference.odt" >>= B.readFile
63+ else defaultODT
61 -- handle pictures
64 -- handle pictures
62 let (newContents, pics) =
65 let (newContents, pics) =
63 case runParser pPictures [] "OpenDocument XML contents" xml of
66 case runParser pPictures [] "OpenDocument XML contents" xml of